Wolfgang, thanks for the prompt reply. Inline comments.
On 25 March 2014 09:12, Wolfgang Laun <wolfgang.l...@gmail.com> wrote: > 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.) > This is exactly what we did (the "pretentiously called" pub/sub pattern). declare CronTrigger @role( event ) @timestamp( timestamp ) interval : String timestamp : Date end declare MetricRequest metric : String end declare Subscription key : String interval : String end And the rules are: // Setup rules rule "Create subscriptions" when then insert( new Subscription("epm", "10s") ); end // Cron management rule "Cron trigger 10s" timer ( cron: 0/10 * * * * ? ) when then entryPoints["triggers"].insert( new CronTrigger( "10s", new Date() ) ); end rule "Subscription" when CronTrigger( $interval := interval ) from entry-point "triggers" Subscription( $interval := interval, $key : key ) then entryPoints["requests"].insert( new MetricRequest($key) ); end // Business rules rule "Create counter" when $e : SynthEvent() from entry-point "synth" then entryPoints["counters"].insert( new EventCounter( $e.getId(), "event", $e.getTimestamp() ) ); end // Metrics rule "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) ) then logger.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(.). > > Good to know. Still, the system hangs (i.e. no EventCounter event created) no matter which method I use (session.insert(e), session.getEntryPoint("synth").insert(e) or session.execute(CommandFactory.newInsert(e, null, false, "synth")). 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't working properly but further testing proved I was wrong. > 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!) > > 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. Hopefully, with the help of the Drools' Community we'll manage to solve our current issues ;) So said: 1. No matter how we add events to the session, at some point the "Create counter" rule stops triggering and inferred events aren't created anymore. 2. 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). Hope we'll get some help from this valuable community. Thanks, Vieri Cheers > -W P.S. Full source code (not much more than I posted here) available on request. Just to speed up things a bit ;) > > On 25/03/2014, Vieri <vieri.emili...@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 > -- Vieri Emiliani
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users