Inline.
2011/7/25 Melton, Michael P CTR SPAWARSYSCEN-ATLANTIC, 01200 <
michael.melton.ctr(a)navy.mil>
# If two WorkerInWorkEvents exist for a worker, there must be a
WorkerOutOfWorkEvent between them
rule "ERROR: Consecutive WorkerInWorkEvents"
when
$w1 : WorkerInWorkEvent( $workerId : workerId )
$w2 : WorkerInWorkEvent( workerId == $workerId, this after
$w1 )
not WorkerOutOfWorkEvent( workerId == $workerId, this after
$w1, this before $w2 )
then
errors.add("Two WorkerInWorkEvents without a
WorkerOutOfWorkEvent in between (" + $w2 + ")");
retract( $w2 );
end
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.
Feel free to raise a JIRA if you think otherwise.
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
- a WorkerOutOfWorkEvent without a matching WorkerInWorkEvent is an error
and retracts it
- a WorkerOutOfWorkEvent with a matching WorkerInWorkEvent creates a
WorkerWorking event and retracts both
- a WorkerInWorkEvent during a WorkerWorking is an error etc.
- (etc)
-W
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 (
http://drools.46999.n3.nabble.com/Drools-fusion-and-absence-of-events-td5...)
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.
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?
Thanks in advance for any light you can shed on this.
Mike
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users