I need your help to put to work an accumulate function.
So, i will introduce several facts into working memory (StateEvent, which i declare as event) and i want to accumulate the last five values.
I have changed a property in drools.default.rulebase.conf (drools.eventProcessingMode = STREAM) to make the engine works in stream mode.
And my rule is:
declare StateEvent
@role( event )
end
rule "Testing"
when
$total : Number() from accumulate(
StateEvent(itemName=="Temperatura", $val : newState) over window:length( 5 ),
sum ( ((DecimalType)$val).toBigDecimal().doubleValue() ) )
then
#actions
end
But it's not working, as the value of $total is 0.0, no matter what i do, and the rule is firing with every fact in the working memory.
Any help will be appreciated.
Thanks