[rules-users] Initial rule delay

Paul R. reverselogic at gmail.com
Thu Jun 7 06:55:41 EDT 2012


Hi Wolfgang,

I've attached a simple test case, which demonstrates the repetitions. If
you run it, you'll see that the rule fires 3 times. [Tested in 5.4]

count = 5, time = 5000ms
count = 5, time = 10000ms
count = 5, time = 15000ms

Changing the repeat-interval to 0 has identical results. Changing to a
negative number [suggested earlier] causes an infinite loop in Drools.

To clarify, what I'm trying to do is block the rule from firing for the
first 5 seconds and then fire normally after that ( as if there was no
timer ). For example. The output I'm trying to achieve (not necessarily
with timers) is:

count = 5, time = 5000ms
count = 5, time = 6000ms
count = 5, time = 7000ms
count = 5, time = 8000ms
count = 5, time = 9000ms
count = 5, time = 10000ms
count = 5, time = 11000ms
count = 5, time = 12000ms
count = 5, time = 13000ms
count = 5, time = 14000ms
count = 5, time = 15000ms

Thanks & Regards,

Paul

On Thu, Jun 7, 2012 at 7:41 AM, Wolfgang Laun <wolfgang.laun at gmail.com>wrote:

> On 07/06/2012, Mark Proctor <mproctor at codehaus.org> wrote:
> > On 06/06/2012 18:39, Vincent LEGENDRE wrote:
> >> try with a negative number ?
> > I would ommit the number all together. I suspect what 0 does is schedule
> > with intervals of 0s, thus it fires straight away.
> > timer(int: 5s)
>
> @myself: I really should RFTM before proposing risky (if working)
> workarounds.
>
> The OP's claim  "if the repeat interval is omitted, it uses the
> initial delay as the repeat interval" is, untrue; DRL timer's
> definition is in line with all similar APIs and definitions, i.e.,
> when the repeat interval is omitted, then it's a one shot timer.
>
> @Paul: As I wrote in a previous mail - there's got to be another
> effect that causes the repetitions. Note that a live timer is
> connected to an *activation*, which isn't the same as being connected
> to a *rule*:
>   1 rule - n activations - n timers - x firings.
>
> -W
>
> >
> > Mark
> >>
> >> ----- Original Message -----
> >> From: "Paul R."<reverselogic at gmail.com>
> >> To: "Rules Users List"<rules-users at lists.jboss.org>
> >> Sent: Mercredi 6 Juin 2012 19:26:22
> >> Subject: Re: [rules-users] Initial rule delay
> >>
> >>
> >> Thanks Wolfgang, but setting the repeat-interval to 0 seems to have the
> >> same effect as omitting the repeat-interval [Tested in 5.1&  5.4].
> >>
> >>
> >> Thanks Vincent, this seems to work. However I was hoping for a simpler
> >> solution :)
> >>
> >>
> >> - Paul
> >>
> >> On Wed, Jun 6, 2012 at 5:06 PM, Vincent LEGENDRE<
> >> vincent.legendre at eurodecision.com>  wrote:
> >>
> >>
> >> Yes of course ...
> >> Simpler this way ...
> >>
> >>
> >> ----- Original Message -----
> >> From: "Wolfgang Laun"<  wolfgang.laun at gmail.com>
> >> To: "Rules Users List"<  rules-users at lists.jboss.org>
> >>
> >>
> >> Sent: Mercredi 6 Juin 2012 18:02:40
> >> Subject: Re: [rules-users] Initial rule delay
> >>
> >> Try:
> >> timer( int:<initial>  0 )
> >> -W
> >>
> >> On 06/06/2012, Paul R.<  reverselogic at gmail.com>  wrote:
> >>> 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 at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120607/f0d48473/attachment-0003.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TimerTest.java
Type: application/octet-stream
Size: 3258 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20120607/f0d48473/attachment-0003.obj 


More information about the rules-users mailing list