[rules-users] Drools variables

Mark Proctor mproctor at codehaus.org
Tue Apr 24 22:02:11 EDT 2012


On 24/04/2012 18:43, skatta1986 wrote:
> 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
Expressions are not supported in 5.3 release. The matching code may not 
be correct identifying your invalid expression. You can see the code 
here, buildtimers() method. If you can see how we can tighten the code 
better, please let me know:
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java

5.4 adds support for time expressions. Which will be released soon 
(within next two weeks).

Mark
>
> -------------------------------------------------------------
> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users



More information about the rules-users mailing list