You can find sample code in https://github.com/lome/lome_intext
Sample codes insert 1K Myfacts/seconds and aggregates them using the following rule:
rule "Dummy"
timer( cron:0/5 * * * * ? )
when
Number( $count : intValue ) from accumulate( MyFact( ) over window:time(5s) from entry-point EventStream, sum(1) )
then
System.out.println($count+" myfact(s) seen in the last 5 seconds");
end
After a while, the process goes out of memory.
Profiler Screenshot
Profiler Memory Inspect
As comparison, using the same event injector, this rule was also used:
declare MyFact
@role( event )
@timestamp( timestamp )
@expires( 5s )
end
rule "Dummy"
timer( cron:0/5 * * * * ? )
when
Number( $count : intValue ) from accumulate( MyFact( ) from entry-point EventStream, sum(1) )
then
System.out.println($count+" myfact(s) seen in the last 5 seconds");
end
Reaching the same result of aggregating over a fixed time window, but, this time, the memory consumption and usage turns out to be way better
Profiler Screenshot
Profiler Memory Inspect