<div dir="ltr">Mario,<div>My fault. Here you are the drls:</div><div><br></div><div><b><u>Not working </u></b>(log #1 in my last mail)</div><div><i>[This is the drl I included in my first post to the list. The accumulate occurs in the when clause of the cron based rule.]</i></div>
<div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><div><font face="courier new, monospace">package it.intext.unity.test</font></div></div></div><div><div><div><font face="courier new, monospace"><br>
</font></div></div></div><div><div><div><font face="courier new, monospace">import it.intext.unity.test.SynthEvent;</font></div></div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div>
<div><div><font face="courier new, monospace">import java.util.Date;</font></div></div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">global org.slf4j.Logger logger;</font></div>
</div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">declare SynthEvent // The class is the same you used in previous tests</font></div>
</div></div><div><div><div><font face="courier new, monospace"> @role( event )</font></div></div></div><div><div><div><font face="courier new, monospace"> @timestamp( timestamp )</font></div></div></div><div><div><div>
<font face="courier new, monospace">end</font></div></div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">declare EventCounter</font></div>
</div></div><div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>@role( event )</font></div></div></div><div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>@timestamp( timestamp )</font></div>
</div></div><div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>id <span class="" style="white-space:pre">                        </span>: long</font></div></div></div><div><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><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><div><font face="courier new, monospace">end</font></div>
</div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><font face="courier new, monospace">// Business rules</font></div></div><div><div><font face="courier new, monospace">rule "Create counter"</font></div>
</div><div><div><font face="courier new, monospace"> when</font></div></div><div><div><font face="courier new, monospace"> <span class="" style="white-space:pre">        </span>$e : SynthEvent() from entry-point "synth"</font></div>
</div><div><div><font face="courier new, monospace"> then</font></div></div><div><div><font face="courier new, monospace"> <span class="" style="white-space:pre">        </span>entryPoints["counters"].insert( new EventCounter( $e.getId(), "event", $e.getTimestamp() ) );</font></div>
</div><div><div><font face="courier new, monospace"> <span class="" style="white-space:pre">        </span>// if (Math.random() < 0.001) logger.debug("New event: {}", $e.getId());</font></div></div><div><div><font face="courier new, monospace">end</font></div>
</div><div><div><font face="courier new, monospace"> </font></div></div><div><div><font face="courier new, monospace">// Metrics</font></div></div><div><div><font face="courier new, monospace"><br></font></div></div><div>
<div><font face="courier new, monospace">rule "Count epm"</font></div></div><div><div><font face="courier new, monospace"> timer ( cron: 0/10 * * * * ? )</font></div></div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>when</font></div>
</div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span> Number( $count : intValue ) from accumulate(</font></div></div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span> EventCounter( key == "event" ) over window:time( 60s ) from entry-point "counters", count(1) )</font></div>
</div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>then</font></div></div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span> logger.debug("epm = {}", $count );</font></div>
</div><div><div><font face="courier new, monospace">end</font></div></div><div><div><font face="courier new, monospace"><br></font></div></div><div><div><font face="courier new, monospace">rule "Count live counters"</font></div>
</div><div><div><font face="courier new, monospace"> timer ( cron: 0/60 * * * * ? )</font></div></div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>when</font></div></div>
<div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span> Number( $count : intValue ) from accumulate(</font></div></div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span> EventCounter( key == "event" ) from entry-point "counters", count(1) )</font></div>
</div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>then</font></div></div><div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span> logger.debug("Live counters = {}", $count );</font></div>
</div><div><div><font face="courier new, monospace">end</font></div></div><div><font face="courier new, monospace"><br></font></div></blockquote><span style="font-family:'courier new',monospace"> </span><br><div><span style="font-family:'courier new',monospace"><br>
</span></div><div><div><b><u>Working </u></b>(log #3 in my last mail)</div><div><i>[This is the drl you posted in your reply. Here you can see the CronTrigger usage. Cron based rule has empty LHS, and RHS inserts a trigger, accumulate occurs in a standard (not cron based) rule]</i></div>
<div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><font face="courier new, monospace">package it.intext.unity.test</font></div></div></div><div><div><div><font face="courier new, monospace"><br>
</font></div></div></div><div><div><div><font face="courier new, monospace">import it.intext.unity.test.SynthEvent;</font></div></div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div>
<div><div><font face="courier new, monospace">import java.util.Date;</font></div></div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">global org.slf4j.Logger logger;</font></div>
</div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">declare SynthEvent </font></div></div></div><div><div><div><font face="courier new, monospace"> @role( event ) </font></div>
</div></div><div><div><div><font face="courier new, monospace"> @timestamp( timestamp ) </font></div></div></div><div><div><div><font face="courier new, monospace">end </font></div></div></div><div><div><div><font face="courier new, monospace"><br>
</font></div></div></div><div><div><div><font face="courier new, monospace">declare EventCounter </font></div></div></div><div><div><div><font face="courier new, monospace"> @role( event ) </font></div></div></div><div>
<div><div><font face="courier new, monospace"> @timestamp( timestamp ) </font></div></div></div><div><div><div><font face="courier new, monospace"> id : long </font></div></div></div><div><div><div><font face="courier new, monospace"> key : String </font></div>
</div></div><div><div><div><font face="courier new, monospace"> timestamp : Date </font></div></div></div><div><div><div><font face="courier new, monospace">end </font></div></div></div><div><div><div><font face="courier new, monospace"><br>
</font></div></div></div><div><div><div><font face="courier new, monospace">declare CronTrigger end </font></div></div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">rule "Trigger Metric" </font></div>
</div></div><div><div><div><font face="courier new, monospace">timer ( cron: 0/10 * * * * ? )</font></div></div></div><div><div><div><font face="courier new, monospace">when </font></div></div></div><div><div><div><font face="courier new, monospace">then </font></div>
</div></div><div><div><div><font face="courier new, monospace"> entryPoints["triggers"].insert( new CronTrigger() ); </font></div></div></div><div><div><div><font face="courier new, monospace">end </font></div>
</div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">rule "Create counter" </font></div></div></div><div><div><div><font face="courier new, monospace">when </font></div>
</div></div><div><div><div><font face="courier new, monospace">$e : SynthEvent() from entry-point "synth" </font></div></div></div><div><div><div><font face="courier new, monospace">then </font></div></div></div>
<div><div><div><font face="courier new, monospace"> entryPoints["counters"].insert(new EventCounter( $e.getId(), "event", $e.getTimestamp() ) ); </font></div></div></div><div><div><div><font face="courier new, monospace">end </font></div>
</div></div><div><div><div><font face="courier new, monospace"><br></font></div></div></div><div><div><div><font face="courier new, monospace">rule "Count epm" </font></div></div></div><div><div><div><font face="courier new, monospace">when </font></div>
</div></div><div><div><div><font face="courier new, monospace"> $trigger : CronTrigger() from entry-point "triggers" </font></div></div></div><div><div><div><font face="courier new, monospace"> Number( $count : intValue ) from accumulate( </font></div>
</div></div><div><div><div><font face="courier new, monospace"> EventCounter( key == "event" ) over window:time( 60s )from entry-point "counters", count(1) ) </font></div></div></div><div><div>
<div><font face="courier new, monospace">then </font></div></div></div><div><div><div><font face="courier new, monospace"> System.out.println("[" + new Date() + "] epm = " + $count ); </font></div></div>
</div><div><div><div><font face="courier new, monospace"> retract($trigger); </font></div></div></div><div><div><div><font face="courier new, monospace">end </font></div></div></div></blockquote><div><div><br></div><div>
<br></div><div>The code used to run the tests is the one we both used in our previous test session. For details you can mail me directly.</div><div>Thanks,</div><div>Vieri</div><div></div></div></div>