Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drools - Repeated Events and Temporal Relations

In general I am writing rules for events which equal (by attributes values) events can occur any time in consecutive manner (every second). I want to fire rules for matched events only on an hourly bases.

In more details: I want to fire a rule when an event is inserted for the first time (not exist yet) OR when an event is inserted and if and only if equal events are already inserted to the working memory BUT the newest of them is at least one hour ago old.

What is a reasonable way of writing a rule of that kind, taking events duration will be 24H?

like image 917
Rod Avatar asked Dec 11 '10 07:12

Rod


1 Answers

rule X
when
    $e : MyEvent() from entry-point "s"
    not( MyEvent( this != $e, id == $e.id, this before[0s,1h] $e ) from entry-point "s" )
then
    // $e arrived and there is no other event with the same
    // id that happened during the last hour
end

Replace "id == $e.id" by whatever constraints you use to decide two events are related to each other.

like image 191
Edson Tirelli Avatar answered Oct 09 '22 02:10

Edson Tirelli