Drools - Repeat Events and Temporary Relationships

In general, I write rules for events that by value (attribute values) can occur at any time in a row (every second). I want to run rules for consistent events on an hourly basis only.

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

What is a reasonable way to write such a rule if the duration of the events is 24H?

+5
source share
2 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

"id == $e.id" , , .

+1

:

global java.util.List eventQueue;

java, :

session.getGlobals();
session.setGlobal(name, value);

. java- , . , .

0

All Articles