In 5.4 timers support expressions for values.
You can thus use a fact used to hold timer values (init and delay). This fact is created
with some non-zero values, and reset all to zero once a first rule has triggered
rule "delayAtFirstTime" timer(expr: $timerSpec.getDelay()+"s" ,
"0s")
when
$timerSpec : TimerSpec()
....
then
....
$timerSpec.setDelay(0);
update($timerSpec);
end
Another solution is to create a fact that enable rule triggering that you insert
"later" (may be that's the problematic aspect ...), something like that
rule "DoSomethingWhenYouCan"
when
exists( OkToGo() )
....
then
...
end
Note that the OkToGo() fact can be inserted by a rule too ...
rule "OkToGoAfter10s" timer(10s 0)
when
not( OkToGo() )
then
insert( new OkToGo() );
end
----- Original Message -----
From: "Paul R." <reverselogic(a)gmail.com>
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Sent: Mercredi 6 Juin 2012 16:47:03
Subject: [rules-users] Initial rule delay
Hi,
I'm looking for a way to delay a rules initial execution? In the following example, I
would like to prevent the rule from firing when the first "Foo" event is
inserted into the working memory.
rule "DelayTest" when $n : Number() from accumulate( $f : Foo() over
window:time(10s) count($f) ) then // bla end
The timer attribute seems to almost support what I'm looking for, i.e. it allows for
an initial-delay to be specified; but if the repeat interval is omitted, it uses the
initial delay as the repeat interval.
timer ( int: <initial delay> <repeat interval>? )
In my case I would like to block the execution of the rule for an
"initial-delay" period, but after that time has elapsed the rule should fire
when every time a new "Foo" event is inserted into the working memory. What is
the recommended way to do this?
Thanks & Regards,
Paul
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users