It seems that a full definition of the semantics of @expires is still missing from the Fusion manual. <br><br><a id="d0e1293">&quot;After that time, assuming no rule <b><i>still needs the
  event</i></b>, the engine will expire and remove the event from the session
  automatically.</a>&quot; (Emphasis by me.)<br><br>So, when does a rule &quot;need an event&quot;? This is a very iffy definition.<br><br>Consider:<br>   when<br>      Event()<br>   then<br>This rule certainly &quot;needs&quot; an Event fact, but does it still need it after the first firing? Not unless Event() is modified, which might happen elsewhere. <br>
<br>In the case of a timer() being added to a rule, there is a similar dilemma. A rule like<br>  rule<br>    timer(int: 5s)<br>  when<br>    Event()<br>  then<br>does and, simultaneously does not, &quot;need&quot; an Event() fact. If Event() is retracted after less than 5s, the rule should not fire - so the rule does not &quot;need&quot; the fact. OTOH, its timed firing depends on the presence of an Event() - so the rule &quot;needs&quot; the fact.<br>
<br>You can easily thwart the algorithm that determines &quot;is needed&quot;:<br><br>rule &quot;check timer attribute&quot;<br>    timer (int: 5s 1s)<br>when<br>    $alert : Object( eval($alert instanceof Alert) ) from entry-point &quot;EventStream&quot;<br>
then<br>     System.out.println( ((Alert)$alert).getId() +<br>                        &quot; time: &quot; + (Calendar.getInstance().getTimeInMillis()));<br>end<br><br>-W<br><br><br><br><div class="gmail_quote">On 28 November 2011 07:32, prashant.badhe <span dir="ltr">&lt;<a href="mailto:prashant.badhe@gmail.com">prashant.badhe@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Here is the complete rule that we trying out with &#39;timer&#39; &amp; &#39;@expires&#39; :<br>

<br>
~~~~~~~~~~~~~<br>
package xyz;<br>
<br>
import abc.Alert;<br>
import abc.CResult;<br>
<br>
import java.util.regex.Matcher;<br>
import java.util.regex.Pattern;<br>
import java.util.ArrayList;<br>
import java.util.HashMap;<br>
import java.util.Iterator;<br>
import java.util.Date;<br>
import java.util.Calendar;<br>
import java.util.Timer;<br>
<br>
declare Alert<br>
        @role( event )<br>
        @expires( 30s )<br>
end<br>
<br>
declare CResult<br>
        @role( event )<br>
        @expires( 30s )<br>
end<br>
<br>
rule &quot;check timer attribute&quot;<br>
        agenda-group &quot;xyz&quot;<br>
        auto-focus true<br>
        no-loop<br>
        salience 140<br>
               timer (int: 5s)<br>
        //duration ( 5s )<br>
<br>
        when<br>
                $alert : Alert( $alertId:id ) from entry-point &quot;EventStream&quot;<br>
        then<br>
                System.out.println(&quot;Inside RHS...[alert=&quot; + $alert.getId() + &quot;]<br>
[Time: &quot; + (Calendar.getInstance().getTimeInMillis()));<br>
<br>
end<br>
~~~~~~~~~~~~~<br>
<br>
We are trying this out on Drools 5.3.0 stateful knowledge session operating<br>
in stream mode.<br>
<br>
The above rule is not firing on inserting Alert fact. If I comment line<br>
&#39;timer (int: 5s 5s)&#39; then it starts firing.<br>
<br>
About the @expires, our assumption is Alert fact inserted is not expiring,<br>
as the count returned by getFactCount() on WM entrypoint object is returned<br>
as 1 even after a thread sleep of more than 60 seconds post the rule firing.<br>
<br>
Please correct us if this assumption is wrong or something more is required<br>
for @expires to work. Similarly for timer(int: 5s) let us know what is<br>
wrong.<br>
<br>
Does the facts that are expired remains in WM but are not evaluated for any<br>
new facts/rules inserted in WM OR they are removed from WM?<br>
<br>
-Prashant<br>
<font color="#888888"><br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3541469.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3541469.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>