I think that this problem is best solved by using an auxiliary fact, let's call it MyPair. it contains two references to MyEvent objects, one called previous, the other one last, both of which are initially null.
For each e: MyEvent with the desired properties, one rule must fire
when MyPair.previous == null and updata MyPair. previous <- last;
last <- e.
For each e: MyEvent with the desired properties, one rule must fire
when MyPair.previous != null and updata MyPair. previous <- last,
last <- e and execute whatever needs to be done for a pair.
Dealing with "stale" MyEvent events (older than 10 minutes) complicates this a little, but not much.
-W
Hi, I'm also facing the same problem...I've to get latest 3 drools events
which can be received at anytime say within 10 minutes. I tried using
sliding window wherein the window will rotate on the complete expiry time of
drools events.
$E1 : MyEvent(prop1 = "MyProp") from entry-point MyStream
$E2 : MyEvent(prop1 = "MyProp", this != $E1) from entry-point MyStream over
window:time(10m)
Now how can I confirm that $E2 is the latest one I mean 2nd latest after the
current one received and also how can I confirm that $E1 is the latest
received due to which rules are fired. I think for $E1 I can use
window:length(1) but for $E2 I'm not sure . Please suggest
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Is-there-any-way-to-find-out-last-two-events-with-some-common-properties-tp2262553p2270569.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users