<div><br></div> Scott,<div><br></div><div> The event expiration algorithm in Drools works with compile time analysis of temporal constraints. It calculates the transitive closure on the temporal intervals created by each temporal constraint and from that it infers the required time for an event to stay in memory, expiring them after that. Some interactions are pretty hard to calculate manually, but as you already realized, you can enable the Drools MBeans and use jconsole (or visualvm as you mentioned) to inspect them.</div>
<div><br></div><div> In your case, first things first, I assume you are running the engine in STREAM mode? the default is CLOUD mode, and in CLOUD mode there is no expiration of events. Second, there was a bug in one of the released versions of Drools (I think 5.2 or 5.3) that was fixed after where the calculation was wrong if the events were in different packages. Finally, you are using external timestamps for the events (on its attributes), so make sure your clock is in line with the externally timestamped events. </div>
<div><br></div><div> If everything I mentioned is working as expected and your events are still not being expired, please try adding an explicit expiration policy (e.g., @expires( 1m ) ), and submit a bug (JIRA) with your findings.</div>
<div><br></div><div> Edson<br><br><div class="gmail_quote">2011/12/7 Scott Embler <span dir="ltr"><<a href="mailto:stembler@gmail.com">stembler@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>I've recently started using some of the temporal operators
that drools supports (coincides, starts, finishes, during) and have had
trouble with events not being expired, causing severe memory
consumption.<br>
I'd first like to make sure that I'm using these operators appropriately, so as a test case I have rules like:<br><br>declare A<br> @role( event )<br> @timestamp( timestamp )<br> @duration( duration )<br>end<br>
<br>declare B<br> @role( event )<br> @timestamp( timestamp )<br> @duration( duration )<br>end<br><br>rule "coincides events"<br>when<br> $a: A() from entry-point "a"<br> $b: B(this coincides $a) from entry-point "b"<br>
then insert("coincides"); end<br><br>With classes like:<br><br>public class A{<br> public final long timestamp;<br> public final long duration;<br> public A(long timestamp, long duration){<br>
this.timestamp = timestamp;<br> this.duration = duration;<br> }<br>}<br><br>//B is identical to A.<br><br>Using a knowledge base configured with stream mode, and a knowledge session with a pseudo clock I'd run this test:<br>
<br>A a = new A(0, 1000);<br>B b = new B(0, 1000);<br> <br>entryPointA.insert(a);<br>entryPointB.insert(b);<br>clock.advanceTime(1000, TimeUnit.MILLISECONDS);<br>ksession.fireAllRules();<br><br>In
this test I'm expecting that the rule will fire to insert "coincides"
and expire both A and B. But instead, "coincides" is inserted, B is
expired, but A remains in memory permanently. If I use jvisualvm to
inspect the expirationOffset for A, I see that it is the Long.MAX value
of 9223372036854775807. This behavior persists even after adding an
explicit expiration to A. I was under the impression that the offset
would be zero (of close to it) since Drools would only need to retain A
until the clock reaches A's endTimestamp. The documentation does not
cover the calculation of event expiration in great detail, so have I
missed something? Thanks in advance.
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>