[rules-users] Unexpected Accumulate Collect behavior
Wolfgang Laun
wolfgang.laun at gmail.com
Sat Mar 9 03:32:52 EST 2013
If the bad sum after run 2 is the sum of run 1 and the correct value
of run 2, chances are that somehow the BresDetail objects of old runs
are reinserted.
(A stateFUL session retaining old BresDetails might be another reason.)
-W
On 08/03/2013, rymy8564 <ryanjmeyer at gmail.com> wrote:
> I'm using Spring AMQP to read messages from RabbitMQ. After a message is
> read it's deserialized into one header (parent) object and multiple detail
> (child) objects. Those facts are then inserted into a stateless rule
> session. Finally, the updated facts are inserted into a database.
>
> I have several rules that will aggregate the detail facts using either the
> collect or accumulate functions. Here's an example.
>
> rule "Header.TotalDuration"
> when
> h : BresHeader()
> n : Number()
> from accumulate( d : BresDetail(willSendToInvoice==true, uniqueConfID ==
> h.uniqueConfID), sum(d.Duration) )
> then
> h.TotalDuration = new Integer(n.longValue());
> System.out.println("[TotalDuration] rule ran");
> end
>
> If I run this once (reading in one message) in jUnit, the TotalDuration is
> calculated correctly. If I run it in tomcat (continuously reading
> messages)
> the values for TotalDuration are not correct and increase after each each
> pass (message is grabbed, rules ran, facts persisted, repeat) and I can't
> figure out why.
>
> Can anyone shed light on this behavior?
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Unexpected-Accumulate-Collect-behavior-tp4022749.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list