declare NumReading
@role( event )
@expires( 10s )
end
Hello,
I am trying to make a rule to delay firing until a certain amount of time has passed without another event being received. I have set up a loop that goes every 10 seconds in my main application that takes readings and injects them into the ReadingStream. These are like sensor readings.
I have a thread started at initialization that is basically calling fireUntilHalt() and I never call halt until shutdown, and that seams to be working fine.
So basically any time an out of spec reading in my Reading object (<15) is received, I want to wait to see if a FollowUpReading is not received in the next 5 seconds, before I fire the results(The second rule below). The first rule is there just to verify I am indeed detecting NumReadings with values < 15 being injected and that works fine. Now at this point in my appication I am *never* inserting a FollowUpReading object/event, so I would expect the 2nd rule to fire all the time, however the strange thing is that it only fires the first time I receive a reading out of spec. I see rule one fire, then the seond time, but after that any subsequent out of spec readings received(I know they are out of spec, because rule 1 still fires when received) but rule 2 never fires again. It only ever fires one time! This is very confusing. These ar the only 2 rules and the only two object types being inserted to the stream. Know that rule 2 *can* fire because it does once and only once. Why won’t it fire beyond the first time, even though I never insert the FollowUpReading() ?
Thanks,
Chris
declare NumReading
@role( event )
end
declare FollowUpReading
@role(event)
end
rule "Determine out of spec reading"
when
$n : NumReading($r:reading < 15) from entry-point "ReadingStream";
then
System.err.println("Fire off a follow up reading for device: " + $n);
end
rule "Missed degrading confirmation reading"
when
$n : NumReading($r:reading < 15) from entry-point "ReadingStream";
not (FollowUpReading(this after[0s, 5s] $n))
then
System.err.println("No good reading received for: " + $n);
end
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users