<div dir="ltr">Wolfgang,<div><span style="font-family:arial,sans-serif;font-size:13px;white-space:nowrap">thanks for the prompt reply.</span><span style="font-family:arial,sans-serif;font-size:13px;font-weight:bold;white-space:nowrap"> </span><span style="font-family:arial,sans-serif;font-size:13px;white-space:nowrap">Inline comments.</span><br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 25 March 2014 09:12, Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">A rule with timer will only continue firing if its first true state<br>

remains constant. This means that you can&#39;t do what you want to do<br>
this way. (You might set up a rule with a repeating or cron timer that<br>
inserts a Trigger fact that triggers the accumulate and is retracted,<br>
or do some similar haque.)<br></blockquote><div><br></div><div>This is exactly what we did (the &quot;pretentiously called&quot; pub/sub pattern).</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">declare CronTrigger</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>@role( event )</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>@timestamp( timestamp )</font></div></div></div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>interval<span class="" style="white-space:pre">        </span>: String</font></div></div></div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>timestamp <span class="" style="white-space:pre">        </span>: Date</font></div></div></div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><font face="courier new, monospace">end</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><br></font></div></div>
</div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">declare MetricRequest</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>metric<span class="" style="white-space:pre">                </span>: String</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">end</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><br>
</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">declare Subscription</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">
<div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>key<span class="" style="white-space:pre">                        </span>: String</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">
<div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>interval<span class="" style="white-space:pre">        </span>: String</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">
<div><div><font face="courier new, monospace">end</font></div></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div> And the rules are:</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// Setup rules</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><br>
</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">rule &quot;Create subscriptions&quot;</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">
<div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>when</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>then</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">            </span>insert( new Subscription(&quot;epm&quot;, &quot;10s&quot;) );</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">end</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><br>
</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// Cron management</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">
<div><div><font face="courier new, monospace"><br></font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">rule &quot;Cron trigger 10s&quot;</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">    timer ( cron: 0/10 * * * * ? )</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">
<div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>when</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>then</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">            </span>entryPoints[&quot;triggers&quot;].insert( new CronTrigger( &quot;10s&quot;, new Date() ) );</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">end</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><br>
</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">rule &quot;Subscription&quot;</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote">
<div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>when</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">            </span>CronTrigger( $interval := interval ) from entry-point &quot;triggers&quot;</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">            </span>Subscription( $interval := interval, $key : key )</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>then</font></div></div></div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">            </span>entryPoints[&quot;requests&quot;].insert( new MetricRequest($key) );</font></div></div></div></div>
<div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">end</font></div></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// Business rules</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">rule &quot;Create counter&quot;</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">    when</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">    <span class="" style="white-space:pre">        </span>$e : SynthEvent() from entry-point &quot;synth&quot;</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">    then</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">    <span class="" style="white-space:pre">        </span>entryPoints[&quot;counters&quot;].insert( new EventCounter( $e.getId(), &quot;event&quot;, $e.getTimestamp() ) );</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">end</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"> </font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">// Metrics</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace">rule &quot;Count epm&quot;</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>when</font></div></div></div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">            </span>$req : MetricRequest( metric == &quot;epm&quot; ) from entry-point &quot;requests&quot;</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>    Number( $count : intValue ) from accumulate(</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>        EventCounter( key == &quot;event&quot; ) over window:time( 60s ) from entry-point &quot;counters&quot;, count(1) )</font></div>
</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>then</font></div></div></div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>    logger.debug(&quot;epm = {}&quot;, $count );</font></div></div></div></div><div class="gmail_extra">
<div class="gmail_quote"><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>    retract( $req );</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>
<div><font face="courier new, monospace">end</font></div></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
The session.execute(command) is a rather roundabout way for inserting<br>
facts. If you want to be fast,  use session.insert(.).<br>
<br></blockquote><div><br></div><div>Good to know. Still, the system hangs (i.e. no EventCounter event created) no matter which method I use (session.insert(e), session.getEntryPoint(&quot;synth&quot;).insert(e) or session.execute(CommandFactory.newInsert(e, null, false, &quot;synth&quot;)). I cannot see any evidence that proves one method to be less unstable than the others. BTW, it seemed to me that session.insert wasn&#39;t working properly but further testing proved I was wrong.</div>
<div> </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Don&#39;t use rules for keeping track what&#39;s going on, or the Heisenberg<br>
effect will spoil your efforts. It&#39;s better to set up insert/retract<br>
listeners, e.g. for maintaining counters of facts per class. This<br>
might give you a better idea of what goes on and wrong. (We&#39;d all be<br>
interested to hear more about the effect you&#39;ve described!)<br>
<br></blockquote><div><br></div><div>Actually, we are working on a real-time analytic tool and, yes, the capability to generate temporally aggregated metrics, either from original or inferred events, is crucial for us. This synthetic example is just a test case, and I hoped it would go more smoothly. We used ESPER here and there, and Drools Expert in many of our projects. We would love to switch to Drools also for the CEP part, but I must admit I am a bit worried by our initial tests.</div>
<div>Hopefully, with the help of the Drools&#39; Community we&#39;ll manage to solve our current issues ;)</div><div><br></div><div>So said: </div><div><ol><li>No matter how we add events to the session, at some point the <span style="font-family:&#39;courier new&#39;,monospace">&quot;Create counter&quot;</span> rule stops triggering and inferred events aren&#39;t created anymore. <br>
</li><li>If we switch to the pub/sub the system is more stable. Still, it hangs as we either increase the throughput or add complexity (read more rules).</li></ol></div><div><div>Hope we&#39;ll get some help from this valuable community. </div>
<div>Thanks,</div></div><div><br></div><div>Vieri</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Cheers<br>
-W</blockquote><div><br></div><div>P.S. Full source code (not much more than I posted here) available on request. Just to speed up things a bit ;)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
On 25/03/2014, Vieri &lt;<a href="mailto:vieri.emiliani@gmail.com">vieri.emiliani@gmail.com</a>&gt; wrote:<br>
&gt; Dear Drools Experts,<br>
&gt;<br>
&gt;<br>
&gt; *Short version*<br>
&gt;<br>
&gt;<br>
&gt;    1. Cron-based rules triggers (more than once) for a full second, rather<br>
&gt;    than once every defined period;<br>
&gt;    2. After some time, event creation from the drl seems to hang. The &quot;time<br>
&gt;    to hang&quot; decreases as we increase the throughput of incoming events;<br>
&gt;    3. The two issues seem to be somehow related (well, maybe).<br>
&gt;<br>
&gt; *Full version*<br>
&gt;<br>
&gt;<br>
&gt;  We are testing Drools Fusion to implement CEP functionalities in our<br>
&gt; platform. We are performing these tests using Drools 6.0.1.Final.<br>
&gt;... </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><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>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Vieri Emiliani<br><br></div></div>