isn't simply the case of using the "exists" CE?
when exists($e1 : Event( type == "A" ) and
$e2 : Event( type == "A", <hapenned within 15 seconds of
$e1>)
$e3 : Event( type == "A", <hapenned within 15 seconds of
$e1>))
then // do something
Yes, but this approach is not really scalable. Consider the case that a rule
should only fire, if the Event "A" occurs 1000 times within an hour or so.
Then the rule would be quite big...
My approach for this type of rule looks so:
when Event($code : code == "A", $ts1 : timestamp,
processedBy not contains "3xA in 15 sec")
$l : LinkedList(size >= 3) from collect
(Event(code == $code,
processedBy not contains "3xA in 15 sec",
timestamp >= $ts1,
timestamp < (addToDate($ts1, 0, 0, 15))))
then alert("3 A's found in 15 sec, beginning at "+$ts1);
markEventsAsProcessedBy($l, "3xA in 15 sec");
end
It is not as easy to read as yours but here I can change the relevant
parameters relatively easy without size dependency of the rule. This makes the
rule accessible for e.g. template rules which can be instantiated.
BTW, I think you will be glad to know that Drools 5 brings
a whole new bunch of features for CEP processing that will
make your life so much easier, ...
That's nice. Unfortunately I have to develope the system now ... :o)
Alexander