[rules-users] Event Streams

Glenn Macgregor gmacgregor at pocketkings.ie
Tue Feb 16 11:43:53 EST 2010


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/571720eb/attachment.html 


More information about the rules-users mailing list