A rule with timer will only continue firing if its first true state
remains constant. This means that you can't do what you want to do
this way. (You might set up a rule with a repeating or cron timer that
inserts a Trigger fact that triggers the accumulate and is retracted,
or do some similar haque.)
declare CronTrigger@role( event )@timestamp( timestamp )interval : Stringtimestamp : Dateenddeclare MetricRequestmetric : Stringend
declare Subscriptionkey : Stringinterval : Stringend
// Setup rules
rule "Create subscriptions"whentheninsert( new Subscription("epm", "10s") );end
// Cron managementrule "Cron trigger 10s"timer ( cron: 0/10 * * * * ? )whenthenentryPoints["triggers"].insert( new CronTrigger( "10s", new Date() ) );end
rule "Subscription"whenCronTrigger( $interval := interval ) from entry-point "triggers"Subscription( $interval := interval, $key : key )thenentryPoints["requests"].insert( new MetricRequest($key) );end
// Business rulesrule "Create counter"when$e : SynthEvent() from entry-point "synth"thenentryPoints["counters"].insert( new EventCounter( $e.getId(), "event", $e.getTimestamp() ) );end// Metricsrule "Count epm"when$req : MetricRequest( metric == "epm" ) from entry-point "requests"Number( $count : intValue ) from accumulate(EventCounter( key == "event" ) over window:time( 60s ) from entry-point "counters", count(1) )thenlogger.debug("epm = {}", $count );retract( $req );end
The session.execute(command) is a rather roundabout way for inserting
facts. If you want to be fast, use session.insert(.).
Don't use rules for keeping track what's going on, or the Heisenberg
effect will spoil your efforts. It's better to set up insert/retract
listeners, e.g. for maintaining counters of facts per class. This
might give you a better idea of what goes on and wrong. (We'd all be
interested to hear more about the effect you've described!)
Cheers
-W
On 25/03/2014, Vieri <vieri.emiliani@gmail.com> wrote:
> Dear Drools Experts,
>
>
> *Short version*
>
>
> 1. Cron-based rules triggers (more than once) for a full second, rather
> than once every defined period;
> 2. After some time, event creation from the drl seems to hang. The "time
> to hang" decreases as we increase the throughput of incoming events;
> 3. The two issues seem to be somehow related (well, maybe).
>
> *Full version*
>
>
> We are testing Drools Fusion to implement CEP functionalities in our
> platform. We are performing these tests using Drools 6.0.1.Final.
>...
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users