[rules-users] Accumulate function, events and stream processing

Wolfgang Laun wolfgang.laun at gmail.com
Mon Jan 30 13:35:52 EST 2012


Is
   ((DecimalType)$val).toBigDecimal()
working correctly, given what you have in $val?

Also, check that count(1) instead of sum(...) produces the expected value.

-W

On 30/01/2012, Juanker Atina <juankera at gmail.com> wrote:
> 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
>



More information about the rules-users mailing list