流口水documentation表示现在优先使用timer属性而不是duration:
Rules now support both interval and cron based timers, which replace the now deprecated duration attribute.
但我发现这样的规则不起作用:
rule "Expired auth"
timer(int: 5s)
when
$auth : Authorized()
$noauth : NotAuthorized()
then
retract($auth);
retract($noauth);
end
因为当第一次评估时,所有事实都将被删除,并且规则不会按预期安排。 但我发现具有 duration 属性的规则可以正常工作:
rule "Expired auth"
duration(5s)
...
end
那么有没有办法通过定时器来做到这一点?
最佳答案
持续时间映射到间隔计时器,因此它们的工作原理相同。您的问题可能出在其他地方。
关于流口水:计时器与持续时间属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20428747/