[rules-users] timer and duration

Mark Proctor mproctor at codehaus.org
Thu Dec 9 08:35:02 EST 2010


On 09/12/2010 12:30, OlliSee wrote:
> Hello there.
>
> I seem to have trouble with the "timer" operator which is documented to have
> superseded the "duration" operator for use in the rule body. I might have
> something to do with the "not" operator I use in my rule.
>
> Scenario: A is a fact, B is an event
>
> When I write something like this
>
> rule "test"
>       timer(int: 5s 5s)
>       when
>            $a : A()
>            not (exists B(a == $a))
>       then
>            insert(new B($a));         // which means in the new B object: B.a
> = $a
> end

rule "test"
      timer(int: 5s 5s)
      when
           $a : A()
           not B(a == $a)
      then
           insert(new B($a));         // which means in the new B object: B.a
= $a
end

> I expect this rule to fire every 5 seconds if and only if the LHS is true.
>
> I just insert a few A objects at the beginning.
> So I expect this rule to fire ONCE, because it will insert the B event which
> makes this rule's LHS evaluate to false in the future.
> BUT, reality is, this rule fires every 5 seconds, no matter what.
>
> Using the deprecated duration operator with "duration(5s)" instead of the
> timer operator, it works as expected.
>
> I assume, that timer works differently compared to duration. So I conclude
> that duration should coexist. Or am I missing something here on the usage of
> the timer operator?
>
> Thanks in advance.
> Oliver
>
>
>
>
>
>
>
>





More information about the rules-users mailing list