[rules-users] Drools variables

skatta1986 shivaprasad_gdk at yahoo.co.in
Tue Apr 24 13:43:16 EDT 2012


what about the paramaters of timer( int: <initial delay> <repeat interval>? ) 
?

timer(int : 10s) --> is working properly
but timer(int : <global variable name> s ) --> not working 

-------------------------------------------------------------
working Rule:

rule "tmeout case"
timer( int: 10s )
    when
         $request : EventRecord(eventType == "EVENT_REGISTER", user ==
"katta") from entry-point "AggStream" 
        and not (EventRecord( eventType == "EVENT_RESPONSE", ", user ==
"katta", this after[ 0s, 10s ] $request ) from entry-point "AggStream")

     then
          System.out.println("-- timeout for user : "+ $request.getUser() );
end
-----------------------------------------------

Now I want to replace value "10" given in the above rule with a global
variable.

-------------------------------------------------

ksession.setGlobal( "timeout", new Integer(10));


Improper (not working) rule:
global Integer timeout;

rule "tmeout case"
timer( int: timeout.intValue() s )
    when
         $request : EventRecord(eventType == "EVENT_REGISTER", user ==
"katta") from entry-point "AggStream" 
        and not (EventRecord( eventType == "EVENT_RESPONSE", ", user ==
"katta", this after[ 0s, 10s ] $request ) from entry-point "AggStream")

     then
          System.out.println("-- timeout for user : "+ $request.getUser() );
end
------------------------------------------------------

This new rule doesn't give any error but it is giving unexpected result.

For example if a fire only one EventRecord(eventType == "EVENT_REGISTER",
user == "katta") into the working memory, then after 10seconds I should get
timeout.

But for the new rule as soon as I fire the EventRecord it is giving as
timeout.


Please help me in this regard






--
View this message in context: http://drools.46999.n3.nabble.com/Drools-variables-tp3935404p3936009.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list