Primarily this is a problem of inaccurate specification, not so much of Drools or programming. Apparently, the specification doesn't say anything about re-raising an alarm after it has been started and stopped. If you have 6 events of level 5, the alarm ought to be started *and* stopped at the same time...
Perhaps something like this: "Once 3 elements have caused an Alarm to be raised, they cannot do so once again (but they may participate in stopping the Alarm if they are of level 5)." If this is the "missing spec", mark the Events and use the mark as a constraint. -W On 05/11/2013, webfrank <[email protected]> wrote: > Hi everybody, I'm new to drools and I would like to solve this simple > situation: > > I have a rule which will fire when 3 or more events comes from entry-point > with level > 4 in a 10s window: > rule "Got 3 events" > when > not Alarm() > t : Number(intValue > 2) from accumulate ( > e : Event( level > 4) over window:time(10s) from entry-point > "queue", > count(e) > ) > then > insert(new Alarm()); > end > > This way if more events comes with level > 4 no more alarms are sent. > > I have another rule to retract Alarm object when more than 5 events comes > with level < 6 in a 10s window: > > rule "Reset alarm" > when > a : Alarm() > c : Number( intValue > 5) from accumulate ( > e : Event( level < 6) over window:time(10s) from entry-point > "queue", > count(e) > ) > then > retract(a); > end > > The problem is that I got an infinite loop once I retract the Alarm object > and a new is inserted by the first rule. > > How could I solve the problem? Probably a different approach but I'm still > learning. > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Insert-fact-to-be-used-as-semaphore-tp4026651.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
