Inline.<br><br><div class="gmail_quote">2011/7/25 Melton, Michael P CTR SPAWARSYSCEN-ATLANTIC, 01200 <span dir="ltr"><<a href="mailto:michael.melton.ctr@navy.mil">michael.melton.ctr@navy.mil</a>></span>
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><p># If two WorkerInWorkEvents exist for a worker, there must be a WorkerOutOfWorkEvent between them <br>
rule "ERROR: Consecutive WorkerInWorkEvents" <br> when <br> $w1 : WorkerInWorkEvent( $workerId : workerId ) <br> $w2 : WorkerInWorkEvent( workerId == $workerId, this after $w1 ) <br>
not WorkerOutOfWorkEvent( workerId == $workerId, this after $w1, this before $w2 ) <br> then <br> errors.add("Two WorkerInWorkEvents without a WorkerOutOfWorkEvent in between (" + $w2 + ")"); <br>
retract( $w2 ); <br>end </p></div></blockquote><div>I'd say that "this after $w1" makes the Engine wait for ever since after is not bounded. That the truth of $w2 after $w1 is established before the not needs to be evaluated and that this, in combination with "this before $w2" effectually limits the waiting as soon as the second CE is matched is something that would need symbolic expression interpretation - something that's not so easy to program.<br>
<br>Feel free to raise a JIRA if you think otherwise.<br><br>However, temporal reasoning with several "flank" events is tricky. My advice would be to try retain at most one of each kind in WM, and combine them into a WorkerWorking event with a duration as soon as possible. Then<br>
- a WorkerOutOfWorkEvent without a matching WorkerInWorkEvent is an error and retracts it<br> - a WorkerOutOfWorkEvent with a matching WorkerInWorkEvent creates a WorkerWorking event and retracts both<br> - a WorkerInWorkEvent during a WorkerWorking is an error etc.<br>
- (etc)<br><br>-W <br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>
<p>I could see via the log that this file was activating, however it was never firing. The retraction of $w2 should have cancelled other rules' activations, but it wasn't doing so because this rule was never firing. I just discovered a thread (<a href="http://drools.46999.n3.nabble.com/Drools-fusion-and-absence-of-events-td51125.html" target="_blank">http://drools.46999.n3.nabble.com/Drools-fusion-and-absence-of-events-td51125.html</a>) which finally explained to me the reason why: I was running in STREAM mode, and the engine was waiting to see if a WorkerOutOfWorkEvent timestamped between the two WorkerInWorkEvents was going to show up. When I switched to CLOUD mode, the rule fired as expected and my other activations were cancelled as I expected. </p>
<p>Now, my new question is: Since I have not specified any intervals, how long will the engine wait for the WorkerOutOfWorkEvent to show up? Forever? </p>
<p>Thanks in advance for any light you can shed on this. </p>
<p>Mike</p></div>
<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>