<br>   Hi Paul,<br><br>   Unfortunately, the bottom line is that there is no magic. Time windows are always based on the concept of &quot;current time&quot; and to be able to join different streams of events Drools took the decision of having a session-scoped clock. <br>
<br>   The major problem of a fact timestamp be in the &quot;past&quot; is that it might miss the time window. But since we are taking decisions in near real time, the decisions for that window are already taken anyway, so not much that can be done if that happens. <br>
<br>   You asked for usual approaches. There are 2 general approaches that I know and the variations of them: <br><br>1. is to synchronize the incoming event streams. This is possible and common on playback systems, like telco rating/billing just to mention one example. This is not possible on live monitoring systems.<br>
<br>2. is to use a controlled clock based on the arriving of events. In this case, the clock is advanced based on the events arriving. Example: the clock could be advanced based on the most recent timestamp among all events that arrived, or based on the timestamp of a specific type of event that is handled like a heartbeat event.<br>
<br>   In the end, it obviously depends on the use case.<br><br>   Others might have additional suggestions, though.<br><br>   Edson<br><br><div class="gmail_quote">2010/3/27 Paul R. <span dir="ltr">&lt;<a href="mailto:reverselogic@gmail.com">reverselogic@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi Edson.<br><br>Many thanks for the response. Firing the rules before advancing the clock fixes the problem. However,<br>
I&#39;m now looking for suggestions on how I can use time windows - when I have events arriving from multiple<br>
unsynchronized streams :)<br><br>For example, I have two events StreamOne and StreamTwo, which have their own timestamp properties,<br>both of these events are inserted into the a single session.<br><br>StreamOne Data.<br>

<br>timestamp = 2010-03-27 04:20:05, x = 0, y = 0<br>timestamp = 2010-03-27 04:20:10, x = 1, y = 0<br>timestamp = 2010-03-27 04:20:15, x = 1, y = 0<br>timestamp = 2010-03-27 04:20:20, x = 1, y = 0<br>timestamp = 2010-03-27 04:20:25, x = 0, y = 0<br>

<br>StreamTwo Data.<br>
<br>
timestamp = 2010-03-27 04:20:10, x = 0, y = 0<br>
timestamp = 2010-03-27 04:20:15, x = 1, y = 1<br>
timestamp = 2010-03-27 04:20:20, x = 1, y = 1<br>
timestamp = 2010-03-27 04:20:25, x = 0, y = 1<br>timestamp = 2010-03-27 04:20:30, x = 0, y = 1<br><br>I would like to use simple rules like the following to capture particular sequences of data.<br><br>Number(intValue &gt; 2) from accumulate<br>

        $f : StreamOne(x == 1)<br>           
 over window:time ( 15s )<div class="im"><br>            from entry-point 
ChannelDataStream, <br>        count($f))<br><br><br></div>
Number(intValue &gt; 2) from accumulate<br>
        $f : StreamOne(y == 1)<br>
           
 over window:time ( 15s )<div class="im"><br>
            from entry-point 
ChannelDataStream, <br>
        count($f))<br><br></div>Because the timestamps are in the past, and because of the fact that multiple instances of the<br>same event type (different timestamps) may arrive at the same time, due to network latency, etc.<br>

This rules out the use of the real-time clock.<br><br>I also can&#39;t see how I can reliably use the pseudo-clock because of the lack of synchronization<br>of the timestamps between the two streams?<br><br>Any suggestions greatly appreciated!<br>

<br>Thanks and Regards,<br><br>Paul<br><br><br><br><br><br><br><br><br><div class="gmail_quote">2010/3/26 Edson Tirelli <span dir="ltr">&lt;<a href="mailto:ed.tirelli@gmail.com" target="_blank">ed.tirelli@gmail.com</a>&gt;</span><div>
<div></div><div class="h5"><br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>   Did you tried firing the rules before advancing the time clock? <br><br>   This is a very tricky situation because you are working with the edge limits of the time window. Events are expired from the time window when the clock advances. You are inserting events every 5 seconds. So, lets say you insert events on T0, T5, T10, T15, T20, T25... at this point in time the rule activates, but before it fires, you advance the clock to T30, when T0 is expired from the window, making the condition intValue &gt; 5 false and deactivating the rule.<br>



<br>    []s<br>    Edson<br><br><div class="gmail_quote">2010/3/25 Paul R. <span dir="ltr">&lt;<a href="mailto:reverselogic@gmail.com" target="_blank">reverselogic@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


<div><div></div><div>
Hi,<br><br>I&#39;m using an accumulate on a sliding window to count the number of events, which occur in a 30 second window;<br>the events are inserted every 5 seconds - so with a 30 second window, I would expect 6 events to occur.<br>




<br>The rule below never fires, though from the log output, it looks as though the condition has matched successfully?<br><br>declare Foo <br>    @role ( event ) <br>    @expires ( 60s ) <br>    @timestamp ( date ) <br>end<br>




<br>rule &quot;Count Foo&quot;<br>when<br>    c : Number(intValue &gt; 5) from accumulate<br>        $f : Foo()<br>            over window:time ( 30s )<br>            from entry-point ChannelDataStream, <br>        count($f))<br>




then<br>    System.out.println(&quot;Count [30s] = &quot; + c);<br>end<br><br>OBJECT ASSERTED value:com.test.DroolsTest$Foo@c52200 factId: 1<br>OBJECT ASSERTED value:com.test.DroolsTest$Foo@128edf2 factId: 3<br>OBJECT ASSERTED value:com.test.DroolsTest$Foo@1dddba factId: 4<br>




OBJECT ASSERTED value:com.test.DroolsTest$Foo@c7e8a7 factId: 5<br>OBJECT ASSERTED value:com.test.DroolsTest$Foo@7b4703 factId: 6<br>ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0] declarations: c=6(2)<br>



OBJECT ASSERTED value:com.test.DroolsTest$Foo@1732ed2 factId: 7<br>
ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0] declarations: c=6(2)<br>ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0] declarations: c=6(2)<br>OBJECT ASSERTED value:com.test.DroolsTest$Foo@be76c7 factId: 8<br>




ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0] declarations: c=6(2)<br>ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0] declarations: c=6(2)<br><br><br>Can anybody explain why this is happening? I&#39;ve attached a test case, which demonstrates the problem.<br>




<br>Thanks in advance.<br><font color="#888888"><br>- Paul<br>
</font><br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</font><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div></div></div><br>
</blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>