[rules-users] Event Streams

Glenn Macgregor gmacgregor at pocketkings.ie
Tue Feb 16 13:28:55 EST 2010


A bit more information I just gathered:

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

Only fires once for each stream insert I do, so it seems to have something to do with either the window or accumulate in the rule below.

Any help is greatly appreciated.

Thanks

 Glenn

From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Glenn Macgregor
Sent: 16 February 2010 16:44
To: Rules Users List
Subject: [rules-users] Event Streams

Hi All...again,

I am slowly working through my testcase and it seems to be going OK so far. My question is about stored events, @expires set to 1d for instance, and processing rules.

declare ParameterUpdateEvent
      @role(event)
      @expires(1d1h)
End

rule "Print Average"
      no-loop true
      when
            ParameterUpdateEvent($paramName : name, $newParamValue : value)
                  from entry-point "ParamUpdateStream"
            $param : Parameter(name == $paramName)
            $averageUpdateValue : Number(doubleValue >= 1) from accumulate(
                  ParameterUpdateEvent(name == $paramName, $value : value)
                  over window:time(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

Inside my unit test I add a single event to the stream and this rule fires and prints the average value...which is the value of the last update because it is the first event is has seen. I send in another event with a different value and this rule fires twice and prints the correct value both times. From what I can gather this is due to the fact that there are 2 events on the stream at this point even though I have processed one already.

What is the best practice to handling only the last event on a stream? Since the documentation states that events should be immutable I can't add a processed flag.

Thank you for all your support thus far.

 Glenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100216/4f0eb6e6/attachment.html 


More information about the rules-users mailing list