It seems that a full definition of the semantics of @expires is still missing from the Fusion manual. <br><br><a id="d0e1293">"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>" (Emphasis by me.)<br><br>So, when does a rule "need an event"? This is a very iffy definition.<br><br>Consider:<br> when<br> Event()<br> then<br>This rule certainly "needs" 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, "need" an Event() fact. If Event() is retracted after less than 5s, the rule should not fire - so the rule does not "need" the fact. OTOH, its timed firing depends on the presence of an Event() - so the rule "needs" the fact.<br>
<br>You can easily thwart the algorithm that determines "is needed":<br><br>rule "check timer attribute"<br> timer (int: 5s 1s)<br>when<br> $alert : Object( eval($alert instanceof Alert) ) from entry-point "EventStream"<br>
then<br> System.out.println( ((Alert)$alert).getId() +<br> " time: " + (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"><<a href="mailto:prashant.badhe@gmail.com">prashant.badhe@gmail.com</a>></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 'timer' & '@expires' :<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 "check timer attribute"<br>
agenda-group "xyz"<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 "EventStream"<br>
then<br>
System.out.println("Inside RHS...[alert=" + $alert.getId() + "]<br>
[Time: " + (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>
'timer (int: 5s 5s)' 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>