Need a rule which alerts if a certain number of BootNotifications (here 2) occurs in a certain time frame (here 10s).
I came up with the following rule:
rule "MonitorNumberOfReboots"
dialect "mvel"
when
$s : BootNotification()
Number( intValue >= 2 ) from accumulate ( BootNotification() over window:time (10s), count(1))
not (Command(this before [0s, 1h] $s ))
then
Command $c = new Command();
insertLogical( $c );
end
Further explanation:
- Kie-Engine is running in "stateful", "stream", "realtime" and "equality" mode
Testing:
- I tested the rule by adding BootNotification with an interval > 10s => Rule does not fire => check
- I tested the rule by adding BootNotification with an interval 2s => Rule fires many times => fail
Question/Problem:
I don't want the rule to fire many times. When the rules fires, I insert a Command. In when-clause I added a check if Command exists. I expect the rule to not fire more than once in 1h. It doesn't work. Even after 10s it just keeps inserting Command instances.
I thought the problem could my the "this before [0s, 1h] $s" in the third line of when-clause, so I replaced it with
not (Command() over window:time (1h))
but it does fire even more often when add BootNotifications every 2s.