Hi,
I am trying to reproduce the issue you reported, but so far I couldn't. This
is drl I am using:
import org.drools.test.SynthEvent
import java.util.Date
declare SynthEvent
@role( event )
@timestamp( timestamp )
end
declare EventCounter
@role( event )
@timestamp( timestamp )
id : long
key : String
timestamp : Date
end
declare CronTrigger end
rule "Trigger Metric"
timer ( cron: 0/10 * * * * ? )\n
when
then
entryPoints["triggers"].insert( new CronTrigger() );
end
rule "Create counter"
when
$e : SynthEvent() from entry-point "synth"
then
entryPoints["counters"].insert(new EventCounter( $e.getId(),
"event",
$e.getTimestamp() ) );
end
rule "Count epm"
when
$trigger : CronTrigger() from entry-point "triggers"
Number( $count : intValue ) from accumulate(
EventCounter( key == "event" ) over window:time( 60s )from entry-point
"counters", count(1) )
then
System.out.println("[" + new Date() + "] epm = " + $count );
retract($trigger);
end
and this is how I am using it:
final KieSession ksession = kbase.newKieSession();
EntryPoint synthEP = ksession.getEntryPoint("synth");
new Thread(){
public void run() {
ksession.fireUntilHalt();
};
}.start();
long counter = 0;
while(true) {
counter++;
synthEP.insert(new SynthEvent(counter));
try {
Thread.sleep(20L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if ((counter % 1000) == 0) {
System.out.println("Total events: " + counter);
}
}
Note that since you mentioned you expected around 3K events per minute I am
doing a sleep of 20 msec between the insertion of 2 consecutive events. Is
that correct?
I let this run for 10 minutes and I got the output I am pasting at the end
of this email, so I think that it is working as expected. Please let me know
if you'll give a try at my test case and if it works correctly also for you.
Also if you find any further problem feel free to send a reproducer so I
could give it a try.
Regards,
Mario
[Tue Mar 25 13:37:30 CET 2014] epm = 318
[Tue Mar 25 13:37:40 CET 2014] epm = 774
Total events: 1000
[Tue Mar 25 13:37:50 CET 2014] epm = 1259
[Tue Mar 25 13:38:00 CET 2014] epm = 1746
Total events: 2000
[Tue Mar 25 13:38:10 CET 2014] epm = 2233
[Tue Mar 25 13:38:20 CET 2014] epm = 2720
Total events: 3000
[Tue Mar 25 13:38:30 CET 2014] epm = 2890
[Tue Mar 25 13:38:40 CET 2014] epm = 2922
Total events: 4000
[Tue Mar 25 13:38:50 CET 2014] epm = 2926
[Tue Mar 25 13:39:00 CET 2014] epm = 2929
Total events: 5000
[Tue Mar 25 13:39:10 CET 2014] epm = 2933
[Tue Mar 25 13:39:20 CET 2014] epm = 2938
Total events: 6000
[Tue Mar 25 13:39:30 CET 2014] epm = 2944
[Tue Mar 25 13:39:40 CET 2014] epm = 2948
Total events: 7000
[Tue Mar 25 13:39:50 CET 2014] epm = 2952
[Tue Mar 25 13:40:00 CET 2014] epm = 2956
Total events: 8000
[Tue Mar 25 13:40:10 CET 2014] epm = 2958
[Tue Mar 25 13:40:20 CET 2014] epm = 2959
Total events: 9000
[Tue Mar 25 13:40:30 CET 2014] epm = 2959
[Tue Mar 25 13:40:40 CET 2014] epm = 2960
Total events: 10000
[Tue Mar 25 13:40:50 CET 2014] epm = 2960
[Tue Mar 25 13:41:00 CET 2014] epm = 2960
Total events: 11000
[Tue Mar 25 13:41:10 CET 2014] epm = 2961
[Tue Mar 25 13:41:20 CET 2014] epm = 2963
Total events: 12000
[Tue Mar 25 13:41:30 CET 2014] epm = 2964
[Tue Mar 25 13:41:40 CET 2014] epm = 2964
Total events: 13000
[Tue Mar 25 13:41:50 CET 2014] epm = 2966
[Tue Mar 25 13:42:00 CET 2014] epm = 2966
Total events: 14000
[Tue Mar 25 13:42:10 CET 2014] epm = 2967
[Tue Mar 25 13:42:20 CET 2014] epm = 2964
Total events: 15000
[Tue Mar 25 13:42:30 CET 2014] epm = 2965
[Tue Mar 25 13:42:40 CET 2014] epm = 2966
Total events: 16000
[Tue Mar 25 13:42:50 CET 2014] epm = 2965
[Tue Mar 25 13:43:00 CET 2014] epm = 2967
Total events: 17000
[Tue Mar 25 13:43:10 CET 2014] epm = 2966
[Tue Mar 25 13:43:20 CET 2014] epm = 2969
Total events: 18000
[Tue Mar 25 13:43:30 CET 2014] epm = 2969
[Tue Mar 25 13:43:40 CET 2014] epm = 2969
[Tue Mar 25 13:43:50 CET 2014] epm = 2970
Total events: 19000
[Tue Mar 25 13:44:00 CET 2014] epm = 2969
[Tue Mar 25 13:44:10 CET 2014] epm = 2970
Total events: 20000
[Tue Mar 25 13:44:20 CET 2014] epm = 2969
[Tue Mar 25 13:44:30 CET 2014] epm = 2969
Total events: 21000
[Tue Mar 25 13:44:40 CET 2014] epm = 2969
[Tue Mar 25 13:44:50 CET 2014] epm = 2969
Total events: 22000
[Tue Mar 25 13:45:00 CET 2014] epm = 2969
[Tue Mar 25 13:45:10 CET 2014] epm = 2969
Total events: 23000
[Tue Mar 25 13:45:20 CET 2014] epm = 2969
[Tue Mar 25 13:45:30 CET 2014] epm = 2968
Total events: 24000
[Tue Mar 25 13:45:40 CET 2014] epm = 2969
[Tue Mar 25 13:45:50 CET 2014] epm = 2969
Total events: 25000
[Tue Mar 25 13:46:00 CET 2014] epm = 2969
[Tue Mar 25 13:46:10 CET 2014] epm = 2969
Total events: 26000
[Tue Mar 25 13:46:20 CET 2014] epm = 2968
[Tue Mar 25 13:46:30 CET 2014] epm = 2969
Total events: 27000
[Tue Mar 25 13:46:40 CET 2014] epm = 2968
[Tue Mar 25 13:46:50 CET 2014] epm = 2969
Total events: 28000
[Tue Mar 25 13:47:00 CET 2014] epm = 2969
[Tue Mar 25 13:47:10 CET 2014] epm = 2969
Total events: 29000
[Tue Mar 25 13:47:20 CET 2014] epm = 2969
--
View this message in context:
http://drools.46999.n3.nabble.com/rules-users-Drools-Fusion-inconsistenci...
Sent from the Drools: User forum mailing list archive at
Nabble.com.