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.<br><br>
For each e: MyEvent with the desired properties, one rule must fire
when MyPair.previous == null and updata MyPair. previous <- last;
last <- e.<br>
<br>
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.<br><br>Dealing with "stale" MyEvent events (older than 10 minutes) complicates this a little, but not much.<br><br>-W<br>
<br>
<br><br><br><br><br><br><div class="gmail_quote">On 17 January 2011 07:18, Ayush <span dir="ltr"><<a href="mailto:ayush.vatsyayan@alcatel-lucent.com">ayush.vatsyayan@alcatel-lucent.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi, I'm also facing the same problem...I've to get latest 3 drools events<br>
which can be received at anytime say within 10 minutes. I tried using<br>
sliding window wherein the window will rotate on the complete expiry time of<br>
drools events.<br>
<br>
$E1 : MyEvent(prop1 = "MyProp") from entry-point MyStream<br>
$E2 : MyEvent(prop1 = "MyProp", this != $E1) from entry-point MyStream over<br>
window:time(10m)<br>
<br>
Now how can I confirm that $E2 is the latest one I mean 2nd latest after the<br>
current one received and also how can I confirm that $E1 is the latest<br>
received due to which rules are fired. I think for $E1 I can use<br>
window:length(1) but for $E2 I'm not sure . Please suggest<br>
<font color="#888888">--<br>
View this message in context: <a href="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" target="_blank">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</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>