[rules-users] counter in slidingTime window with restriction

Alexander Wolf mail at alexander-wolf.net
Thu Sep 5 03:11:41 EDT 2013


Hey guys, 

I wrote a rule to count the SensorEvents in my KnowledgeSession that have been inserted via entry-point SensorEventStream over the last 3 seconds - but I only want the event to fire, if there were any events in the last 3 seconds at all.

Problem: if there were no recent events, i still get the output:

> Events in last 3 seconds: 0

I don't really get why?! This is my rule code:


rule "slidingTimeCount"
when
	$n: Number (intValue > 0) from accumulate ( $e: SensorEvent() over window:time(3s) from entry-point SensorEventStream, count($e))
then
	System.out.println("Events in last 3 seconds: " + $n);
end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20130905/0346db59/attachment.bin 


More information about the rules-users mailing list