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
Show replies by date
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(a)lists.jboss.org [mailto:rules-users-bounces@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