Hello Edson,<br><br>Ok, it&#39;s clear now. <br>I&#39;ll try my first attempt with the new 5.1M2 version.<br><br>Thank you very much !<br><br>Best regards,<br>Xavier<br><br><div class="gmail_quote">2010/5/27 Edson Tirelli <span dir="ltr">&lt;<a href="mailto:tirelli@post.com">tirelli@post.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>    Xavier (and others),</div><div><br></div><div>    First, let me explain the problem: the temporal distance algorithm in 5.0.1 was not taking sliding windows into consideration when calculating the expiration offset for the objects. So, even declaring a 60s sliding window, the engine thought your expiration offset was 0s, and was expiring them right away. When using &quot;after&quot;, then engine correctly evaluates the expiration offset and the problem does not happen. </div>

<div><br></div><div>    There was a workaround (although for your case using &quot;after&quot; IMO) that is to explicit declare an expiration offset:</div><div class="im"><div><br></div><div><span style="font-family: &#39;courier new&#39;,monospace;">declare Operation</span><br style="font-family: &#39;courier new&#39;,monospace;">

<span style="font-family: &#39;courier new&#39;,monospace;">    @role(event)</span><br style="font-family: &#39;courier new&#39;,monospace;"><span style="font-family: &#39;courier new&#39;,monospace;">    @timestamp(date)</span></div>

</div><div><span style="font-family: &#39;courier new&#39;,monospace;"></span>        @expires( 60s )<br style="font-family: &#39;courier new&#39;,monospace;"><span style="font-family: &#39;courier new&#39;,monospace;">end</span><br style="font-family: &#39;courier new&#39;,monospace;">

</div><div><br></div><div>    This is fixed in 5.1M2 and now the engine does take sliding windows into consideration. </div><div><br></div><div>    In your case, though, using temporal operators like &quot;after&quot; is probably semantically better. Sliding windows are useful when used with accumulate/collect. For instance, if you want to count how many operations the user did in the last 60 seconds:</div>

<div><br></div><div>Number( $count : intValue )  from accumulate(</div><div>    Operation() from entry-point &quot;OperationStream&quot;,</div><div>    count(1) )</div><div><br></div><div>   Sorry for the late answer... I was offline during the last couple weeks. </div>

<div><br></div><div>   Wolfgang, loved your new terminology: pseudo-too-old, pseudo-too-late. :)</div><div><br></div><div>    Edson</div><br><br><div class="gmail_quote">2010/5/27 Xavier Coulon <span dir="ltr">&lt;<a href="mailto:xcoulon@gmail.com" target="_blank">xcoulon@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;">Hello again,<br><br>I&#39;m back on my problem and a colleague of mime suggested me the following rule instead :<div>

<br><br><span style="font-family: courier new,monospace;"># declare events</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">declare Operation</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    @role(event)</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">    @timestamp(date)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">end</span><br style="font-family: courier new,monospace;">


<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">rule &quot;overActivity&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">dialect &quot;mvel&quot;    </span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">    when</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        #condition : 2 operation in less than 1 minute</span><br style="font-family: courier new,monospace;">


</div><span style="font-family: courier new,monospace;">       <b> $operation1 : Operation($ipAddress1 : ipAddress) </b></span><b><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            from entry-point &quot;OperationStream&quot;</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">        $operation2 : Operation(this != $operation1, ipAddress == $ipAddress1,  </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            this after[ 0s,30s ] $operation1) from entry-point &quot;OperationStream&quot;</span></b><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">    then </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        #actions</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">        System.out.println(&quot;over-active user &quot; + $ipAddress1 );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">end</span><br>


<br><br>It works, and the main difference is the use of <b>after[]</b> instead of <b>window:time()</b><br>Is it because the window:time() was used outside of an <b>accumulate()</b> function ?<br>I&#39;d just like to understand this. <br>


If anyone can take a few minutes to answer, thank you in advance<br><br>Best regards,<br><br>Xavier<div><div></div><div><br><br><br><br><div class="gmail_quote">On Wed, May 19, 2010 at 10:08 AM, Xavier Coulon <span dir="ltr">&lt;<a href="mailto:xcoulon@gmail.com" target="_blank">xcoulon@gmail.com</a>&gt;</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;"><div><br>
Hello Wolfgang,<br>
<br>
sorry, I wasn&#39;t available yesterday.<br>
I just followed your instructions:<br>
<br>
Here&#39;s my test method now :<br>
<br>
</div><div>@SuppressWarnings(&quot;unchecked&quot;)<br>
    @Test<br>
    public void testActivity() throws IOException, ParseException,<br>
            InterruptedException {<br>
        // parse the log file<br>
        Resource logFile = new ClassPathResource(<br>
</div>                &quot;activity/activity18h20-18h30-extract.log&quot;);<br>
<div>        // converter and inject tracks in the session,<br>
        List&lt;String&gt; logLines = FileUtils.readLines(logFile.getFile(),<br>
&quot;UTF-8&quot;);<br>
</div><div>        LOGGER.info(&quot;loading events&quot;);<br>
        // load events from stream<br>
</div>        Operation previousOperation = null;<br>
<div>        for (String logLine : logLines) {<br>
            Operation operation = LineConverterUtil.getOperation(logLine);<br>
</div><div>            Assert.assertFalse(&quot;Current operation equals() previous one&quot;,<br>
                    operation.equals(previousOperation));<br>
            Assert.assertFalse(&quot;Current operation == previous one&quot;,<br>
                    operation == previousOperation);<br>
</div>            previousOperation = operation;<br>
<div>            LOGGER.debug(&quot;Moving clock from &quot;<br>
                    + (new Date(clock.getCurrentTime())).toString() + &quot; to &quot;<br>
                    + operation.getDate());<br>
            clock.advanceTime(operation.getDate().getTime()<br>
                    - clock.getCurrentTime(), TimeUnit.MILLISECONDS);<br>
            // clock.advanceTime(10, TimeUnit.SECONDS);<br>
</div><div>            LOGGER.debug(&quot;Inserting &quot; + operation);<br>
            FactHandle operationHandle = entryPoint.insert(operation);<br>
            LOGGER.debug(&quot;Insertion done: &quot; +<br>
operationHandle.toExternalForm());<br>
<br>
        }<br>
</div>        session.fireAllRules();<br>
<div><br>
        LOGGER.info(&quot;done with events&quot;);<br>
        // check...<br>
        Assert.assertTrue(&quot;Rule not fired...&quot;, listener<br>
                .isRuleFired(&quot;overActivity&quot;));<br>
    }<br>
<br>
</div><div>And the logs in the console :<br>
<br>
</div>Console&gt; 2010-05-19 09:57:06|INFO ||DroolsRulesTestCase.testActivity|loading<br>
events<br>
Console&gt; 2010-05-19 09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Moving<br>
<div>clock from Thu Jan 01 01:00:00 CET 1970 to Fri Apr 30 18:26:47 CEST 2010<br>
</div>Console&gt; 2010-05-19<br>
09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Inserting Operation<br>
<div>[date=Fri Apr 30 18:26:47 CEST 2010, executionTime=1, hostname=server1,<br>
ipAddress=1.2.3.4, operation=null, requestSize=0, responseSize=0]<br>
</div>Console&gt; 2010-05-19 09:57:06|WARN<br>
<div>||TrackingWorkingMemoryEventListener.objectInserted|Object inserted: [event<br>
fid:1:1:Operation [date=Fri Apr 30 18:26:47 CEST 2010, executionTime=1,<br>
hostname=server1, ipAddress=1.2.3.4, operation=null, requestSize=0,<br>
responseSize=0]]<br>
</div>Console&gt; 2010-05-19<br>
09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Insertion done: [event<br>
<div>fid:1:1:Operation [date=Fri Apr 30 18:26:47 CEST 2010, executionTime=1,<br>
hostname=server1, ipAddress=1.2.3.4, operation=null, requestSize=0,<br>
responseSize=0]]<br>
</div>Console&gt; 2010-05-19 09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Moving<br>
<div>clock from Fri Apr 30 18:26:47 CEST 2010 to Fri Apr 30 18:27:11 CEST 2010<br>
</div>Console&gt; 2010-05-19<br>
09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Inserting Operation<br>
<div>[date=Fri Apr 30 18:27:11 CEST 2010, executionTime=164, hostname=server1,<br>
ipAddress=1.2.3.4, operation=CONSULTATION, requestSize=1299,<br>
responseSize=895]<br>
</div>Console&gt; 2010-05-19 09:57:06|WARN<br>
<div>||TrackingWorkingMemoryEventListener.objectRetracted|Object retracted:<br>
[event fid:1:1:Operation [date=Fri Apr 30 18:26:47 CEST 2010,<br>
executionTime=1, hostname=server1, ipAddress=1.2.3.4, operation=null,<br>
requestSize=0, responseSize=0]]<br>
</div>Console&gt; 2010-05-19 09:57:06|WARN<br>
<div>||TrackingWorkingMemoryEventListener.objectInserted|Object inserted: [event<br>
fid:2:2:Operation [date=Fri Apr 30 18:27:11 CEST 2010, executionTime=164,<br>
hostname=server1, ipAddress=1.2.3.4, operation=CONSULTATION,<br>
requestSize=1299, responseSize=895]]<br>
</div>Console&gt; 2010-05-19<br>
09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Insertion done: [event<br>
<div>fid:2:2:Operation [date=Fri Apr 30 18:27:11 CEST 2010, executionTime=164,<br>
hostname=server1, ipAddress=1.2.3.4, operation=CONSULTATION,<br>
requestSize=1299, responseSize=895]]<br>
</div>Console&gt; 2010-05-19 09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Moving<br>
<div>clock from Fri Apr 30 18:27:11 CEST 2010 to Fri Apr 30 18:28:47 CEST 2010<br>
</div>Console&gt; 2010-05-19<br>
09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Inserting Operation<br>
<div>[date=Fri Apr 30 18:28:47 CEST 2010, executionTime=1, hostname=server1,<br>
ipAddress=1.2.3.4, operation=null, requestSize=0, responseSize=0]<br>
</div>Console&gt; 2010-05-19 09:57:06|WARN<br>
<div>||TrackingWorkingMemoryEventListener.objectRetracted|Object retracted:<br>
[event fid:2:2:Operation [date=Fri Apr 30 18:27:11 CEST 2010,<br>
executionTime=164, hostname=server1, ipAddress=1.2.3.4,<br>
operation=CONSULTATION, requestSize=1299, responseSize=895]]<br>
</div>Console&gt; 2010-05-19 09:57:06|WARN<br>
<div>||TrackingWorkingMemoryEventListener.objectInserted|Object inserted: [event<br>
fid:3:3:Operation [date=Fri Apr 30 18:28:47 CEST 2010, executionTime=1,<br>
hostname=server1, ipAddress=1.2.3.4, operation=null, requestSize=0,<br>
responseSize=0]]<br>
</div>Console&gt; 2010-05-19<br>
09:57:06|DEBUG||DroolsRulesTestCase.testActivity|Insertion done: [event<br>
<div>fid:3:3:Operation [date=Fri Apr 30 18:28:47 CEST 2010, executionTime=1,<br>
hostname=server1, ipAddress=1.2.3.4, operation=null, requestSize=0,<br>
responseSize=0]]<br>
</div>Console&gt; 2010-05-19 09:57:06|INFO ||DroolsRulesTestCase.testActivity|done<br>
with events<br>
<br>
<div><br>
Strangely, the first operation is retracted when the second one is inserted,<br>
yet, they are not equals()...<br>
<br>
</div>/Xavier<br>
<font color="#888888">--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Fusion-Can-t-detect-2-occurrences-with-sliding-window-tp823141p828505.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Fusion-Can-t-detect-2-occurrences-with-sliding-window-tp823141p828505.html</a><br>




</font><div><div></div><div>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" 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>
</div></div></blockquote></div><br><br clear="all"><br></div></div>-- <br><font color="#888888">Xavier<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><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">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><br><br clear="all"><br>-- <br>Xavier<br>