[rules-users] Fusion 5.5 - Deterministically identifying event insert order?

dunnlow dunnlow at yahoo.com
Tue Sep 24 15:50:44 EDT 2013


I am testing with fusion (5.5) and running into an /intermittent /issue.  I
am trying to track transitions between two big events (BEvent) using a
smaller event (SEvents) with the properties I care about.  The idea is that
I will maintain many SEvents in memory for the different kinds of BEvents. 
My basic steps (partly driven by salience) are:

1) rule a:  (salience=100): when a new BEvent is inserted, insert a new
related SEvent
2) rule b: (salience=50): If there are two SEvents for this type of BEvent,
compare them (old vs new) and act accordingly
3) rule c: (salience=0) remove the *old* SEvent (keeping the latest one)
4) rule d: (salience=-50) retract the BEvent

My rule c (above) is:
when $se1 : SEvent(name matches "auto")
         $se2 : SEvent(this after $se1, style matches ($se1.style))
then
   retract($se1);
end;

I am of course running in stream mode and this USUALLY works, but sometimes
rule c does not get activated - based on the audit log.  Also, I have a
DebugWorkingMemoryEventListener configured and I can see that two SEvents DO
exist in working memory which should activate it.  

In my test, I have a loop in which I am inserting events.  When I add a
brief delay, I have not seen a failure.  My guess is that the timestamps on
the two events are the same, thus the "after" is causing the issue. 
However, I am unable to test this as the timestamp on the event is not
accessible (from what I have found on this forum). 

I saw a suggestion here about using a variable on my SEvent to tell the
difference between a new and old version.  I also considered using some sort
of counter bean to order the SEvents (although I believe it would need to be
serialized).

My questions: 
1) Do you agree with my assessment?  Is it possible in stream mode to have
two events with the same timestamp?
2) what is the BEST way to identify which event was inserted first?

Thanks for any insight!
-J





--
View this message in context: http://drools.46999.n3.nabble.com/Fusion-5-5-Deterministically-identifying-event-insert-order-tp4026117.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list