[rules-users] duration attribute & other rule language features issue

prashant.badhe prashant.badhe at gmail.com
Mon Nov 28 01:32:12 EST 2011


Here is the complete rule that we trying out with 'timer' & '@expires' :

~~~~~~~~~~~~~
package xyz;

import abc.Alert;
import abc.CResult;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.Calendar;
import java.util.Timer;

declare Alert
	@role( event )
	@expires( 30s )
end

declare CResult
	@role( event )
	@expires( 30s )
end

rule "check timer attribute"
	agenda-group "xyz"
	auto-focus true
	no-loop
	salience 140
               timer (int: 5s)
	//duration ( 5s )
	
	when	
		$alert : Alert( $alertId:id ) from entry-point "EventStream"
	then
  	        System.out.println("Inside RHS...[alert=" + $alert.getId() + "]
[Time: " + (Calendar.getInstance().getTimeInMillis()));

end
~~~~~~~~~~~~~

We are trying this out on Drools 5.3.0 stateful knowledge session operating
in stream mode.

The above rule is not firing on inserting Alert fact. If I comment line
'timer (int: 5s 5s)' then it starts firing.

About the @expires, our assumption is Alert fact inserted is not expiring,
as the count returned by getFactCount() on WM entrypoint object is returned
as 1 even after a thread sleep of more than 60 seconds post the rule firing.

Please correct us if this assumption is wrong or something more is required
for @expires to work. Similarly for timer(int: 5s) let us know what is
wrong.

Does the facts that are expired remains in WM but are not evaluated for any
new facts/rules inserted in WM OR they are removed from WM?

-Prashant




--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3541469.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list