[rules-users] Unexpected Accumulate Collect behavior

rymy8564 ryanjmeyer at gmail.com
Fri Mar 8 16:48:41 EST 2013


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.


More information about the rules-users mailing list