Hi Edson,

 

Thanks for the response, I guess I jumped the gun on that question because I am seeing some *strange* behaviour long before the expire time.

 

 I have built an app which uses JUnit as the testing framework which I am testing a set of CEP (time based) rules.

 

declare ParameterUpdateEvent

      @role(event)

end

 

rule "Set Parameter Value"

      when

            ParameterUpdateEvent($name : name, $newParamValue : value)

                  from entry-point "ParamUpdateStream"

            $param : Parameter(name == $name)

      then

            $param.setValue($newParamValue);

            System.out.println("New value = " + $param.getValue());

End

 

rule "Print Average"

      when

            ParameterUpdateEvent($paramName : name, $newParamValue : value)

                  from entry-point "ParamUpdateStream"

            $param : Parameter(name == $paramName)

            Number($averageUpdateValue : doubleValue) from accumulate(

                  ParameterUpdateEvent(name == $paramName, $value : value)

                  over window:length( 15m )

                  from entry-point "ParamUpdateStream", average($value))

                 

            #Number($averageUpdateValue : doubleValue)

      then

            #System.out.println("Here");

            System.out.println("Average update value for " + $paramName +

                  " = " + $averageUpdateValue);

End

 

In my unit test I create the necessary Parameter and add it to working memory using session.insert, then I begin adding the events, ParameterUpdateEvent using stream.insert, then call session.fireAllRules.

 

·         Add value 56 – output of Print Average is 56.0

·         Add Value 89 – output of Print Average is 72.5

·         Add value 3 – output of Print Average is 49.33

·         Add value 50 – output of Print Average is 49.5

·         Add value 90 – output of Print Average is 57.6

 

First issue is the Print Average rule gets called for each ParameterUpdateEvent in the stream, called once after I add the 56, called twice after I add the 72.5, three times after 3, etc. but the Set Parameter Value rule is only called once per event. This could be the root of the problem but I am stumped as to why it is happening.

 

Is also seems averages are being computed differently when I add an advanceTime call to the pseudo clock before each event insert but I can’t get clean data due to the above problem.

 

Thanks

 

 Glenn

 

From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: 15 February 2010 20:08
To: Rules Users List
Subject: Re: [rules-users] CEP Question

 


   Hi Glen,

   The averages are indeed recalculated on event expiration. Example:

You have values for the following events:

e1: 20
e2: 30
e3: 40

    So the average is 30. Whenever e1 is expired in your window, the average is recalculated to 35 (assuming no new event arrived).

    What are you seeing there?

    Edson

2010/2/15 Glenn Macgregor <gmacgregor@pocketkings.ie>

Hi All,

 

I am still working through a CEP use case which is going fairly well. I have a few rules and it seems they are working as I expect. Is there a way to get called back when events go out of a time window? My current use case is alerting, I have a stream of events (param updates) coming in and I create a ParamUpdateEvent for each. I have a rule which averages the values in the ParamUpdateEvent and tests against a threshold, that is working fine. The problem is when I don’t receive any events for a period of time over the window size I really want to the rule which calculates the average to fire when anything is moved out of the window as well as when an update arrives, is this possible?

 

Thanks

 

 Glenn


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com