Below is my idea. <br>The rule check that there is <br>1) no event between E1 and E2 and <br>2) no event after E2 <br>which induce that E1 and E2 are the last 2 event. I think it should work but I didn't test it.<br><br>
rule "Props"<br> when<br> $E1 : MyEvent(prop1 == "MyProp") from entry-point MyStream<br> $E2 : MyEvent(prop1 == "MyProp", this after $E1) from entry-point MyStream<br> // no event in between $E1 and $E2<br>
not (MyEvent(prop1 == "MyProp", this after $E1, this before $E2) from entry-point MyStream)<br> // no event after $E2 ($E2 is the last)<br> not (MyEvent(prop1 == "MyProp", this after $E2) from entry-point MyStream)<br>
then<br> //Do something<br>end<br><br><br><br>Best regards.<br><br><div class="gmail_quote">On Sun, Jan 16, 2011 at 1:26 AM, umesh kumar sain <span dir="ltr"><<a href="mailto:umesh.sain@alcatel-lucent.com">umesh.sain@alcatel-lucent.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>
Is there any way to find out last two events with some common properties. In<br>
my app I'd defined a pojo as drools event whose expiry time is say 5 mins.<br>
Now I want to access the properties of last two events.<br>
<br>
say something like this<br>
<br>
rule "Props"<br>
when<br>
$E1 : MyEvent(prop1 = "MyProp") from entry-point MyStream<br>
$E2 : MyEvent(prop1 = "MyProp", this != $E1) from entry-point MyStream<br>
then<br>
Do something<br>
end<br>
<br>
In the above rule my concern is that since the expiry time is 5 minutes and<br>
I can receive any no of events during this period. How can I be sure that<br>
the above two events $E1 and $E2 are the latest one i.e. last two events<br>
received. I also thought of using sliding window but I don't know when they<br>
are going to be received say 1s, 1m, or 5m.<br>
<br>
kindly suggest<br>
<font color="#888888"><br>
--<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-tp2262553p2262553.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-tp2262553p2262553.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>