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