Thanks Wolfgang, that works for me.<br><br><div class="gmail_quote">On Thu, Jun 7, 2012 at 1:14 PM, Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The several distinct activations created from the rule fire once. To<br>
see this, add this snippet:<br>
<br>
    session.addEventListener( new DefaultAgendaEventListener() {<br>
        public void beforeActivationFired(BeforeActivationFiredEvent event) {<br>
            super.beforeActivationFired( event );<br>
            System.out.println( &quot;EVENT FIRED: &quot; + event );<br>
        }<br>
        public void activationCreated(ActivationCreatedEvent event) {<br>
            super.activationCreated( event );<br>
            System.out.println( &quot;EVENT CREATED: &quot; + event );<br>
        }<br>
 } );<br>
<br>
Also, continue after the loop inserting the events:<br>
<br>
   for (long i = 1; i &lt;= 100; i++) {<br>
            clock.advanceTime(1, TimeUnit.SECONDS);<br>
            session.setGlobal(&quot;time&quot;, clock.getCurrentTime());<br>
            session.fireAllRules();<br>
    }<br>
<br>
Your wish to have the first activation delayed by the timer&#39;s initial<br>
delay is always granted. But you can&#39;t have the very same rule firing<br>
as if there were no timer at all.<br>
<br>
So I guess you&#39;ll have to use the approach where a trigger fact is inserted.<br>
<br>
declare Trigger<br>
end<br>
<br>
rule FirstFoo<br>
timer (int: 5s)<br>
when<br>
    not Trigger()<br>
    Foo() from entry-point EntryPoint<br>
then<br>
    insert( new Trigger() );<br>
end<br>
<br>
rule test<br>
when<br>
   Trigger()<br>
   $count : Number() from accumulate(<br>
       $f : Foo() over window:time(5000ms) from entry-point EntryPoint,<br>
       count($f) )<br>
then<br>
   System.out.println(&quot;count = &quot; + $count + &quot;, time = &quot; + time + &quot;ms&quot;);<br>
end<br>
<br>
Simple enough, I&#39;d say.<br>
<span><font color="#888888">-W<br>
</font></span><div><div><br>
<br>
On 07/06/2012, Paul R. &lt;<a href="mailto:reverselogic@gmail.com" target="_blank">reverselogic@gmail.com</a>&gt; wrote:<br>
&gt; Hi Wolfgang,<br>
&gt;<br>
&gt; I&#39;ve attached a simple test case, which demonstrates the repetitions. If<br>
&gt; you run it, you&#39;ll see that the rule fires 3 times. [Tested in 5.4]<br>
&gt;<br>
&gt; count = 5, time = 5000ms<br>
&gt; count = 5, time = 10000ms<br>
&gt; count = 5, time = 15000ms<br>
&gt;<br>
&gt; Changing the repeat-interval to 0 has identical results. Changing to a<br>
&gt; negative number [suggested earlier] causes an infinite loop in Drools.<br>
&gt;<br>
&gt; To clarify, what I&#39;m trying to do is block the rule from firing for the<br>
&gt; first 5 seconds and then fire normally after that ( as if there was no<br>
&gt; timer ). For example. The output I&#39;m trying to achieve (not necessarily<br>
&gt; with timers) is:<br>
&gt;<br>
&gt; count = 5, time = 5000ms<br>
&gt; count = 5, time = 6000ms<br>
&gt; count = 5, time = 7000ms<br>
&gt; count = 5, time = 8000ms<br>
&gt; count = 5, time = 9000ms<br>
&gt; count = 5, time = 10000ms<br>
&gt; count = 5, time = 11000ms<br>
&gt; count = 5, time = 12000ms<br>
&gt; count = 5, time = 13000ms<br>
&gt; count = 5, time = 14000ms<br>
&gt; count = 5, time = 15000ms<br>
&gt;<br>
&gt; Thanks &amp; Regards,<br>
&gt;<br>
&gt; Paul<br>
&gt;<br>
&gt; On Thu, Jun 7, 2012 at 7:41 AM, Wolfgang Laun<br>
&gt; &lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;wrote:<br>
&gt;<br>
&gt;&gt; On 07/06/2012, Mark Proctor &lt;<a href="mailto:mproctor@codehaus.org" target="_blank">mproctor@codehaus.org</a>&gt; wrote:<br>
&gt;&gt; &gt; On 06/06/2012 18:39, Vincent LEGENDRE wrote:<br>
&gt;&gt; &gt;&gt; try with a negative number ?<br>
&gt;&gt; &gt; I would ommit the number all together. I suspect what 0 does is<br>
&gt;&gt; &gt; schedule<br>
&gt;&gt; &gt; with intervals of 0s, thus it fires straight away.<br>
&gt;&gt; &gt; timer(int: 5s)<br>
&gt;&gt;<br>
&gt;&gt; @myself: I really should RFTM before proposing risky (if working)<br>
&gt;&gt; workarounds.<br>
&gt;&gt;<br>
&gt;&gt; The OP&#39;s claim  &quot;if the repeat interval is omitted, it uses the<br>
&gt;&gt; initial delay as the repeat interval&quot; is, untrue; DRL timer&#39;s<br>
&gt;&gt; definition is in line with all similar APIs and definitions, i.e.,<br>
&gt;&gt; when the repeat interval is omitted, then it&#39;s a one shot timer.<br>
&gt;&gt;<br>
&gt;&gt; @Paul: As I wrote in a previous mail - there&#39;s got to be another<br>
&gt;&gt; effect that causes the repetitions. Note that a live timer is<br>
&gt;&gt; connected to an *activation*, which isn&#39;t the same as being connected<br>
&gt;&gt; to a *rule*:<br>
&gt;&gt;   1 rule - n activations - n timers - x firings.<br>
&gt;&gt;<br>
&gt;&gt; -W<br>
&gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Mark<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; ----- Original Message -----<br>
&gt;&gt; &gt;&gt; From: &quot;Paul R.&quot;&lt;<a href="mailto:reverselogic@gmail.com" target="_blank">reverselogic@gmail.com</a>&gt;<br>
&gt;&gt; &gt;&gt; To: &quot;Rules Users List&quot;&lt;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<br>
&gt;&gt; &gt;&gt; Sent: Mercredi 6 Juin 2012 19:26:22<br>
&gt;&gt; &gt;&gt; Subject: Re: [rules-users] Initial rule delay<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Thanks Wolfgang, but setting the repeat-interval to 0 seems to have<br>
&gt;&gt; &gt;&gt; the<br>
&gt;&gt; &gt;&gt; same effect as omitting the repeat-interval [Tested in 5.1&amp;  5.4].<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Thanks Vincent, this seems to work. However I was hoping for a simpler<br>
&gt;&gt; &gt;&gt; solution :)<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; - Paul<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Wed, Jun 6, 2012 at 5:06 PM, Vincent LEGENDRE&lt;<br>
&gt;&gt; &gt;&gt; <a href="mailto:vincent.legendre@eurodecision.com" target="_blank">vincent.legendre@eurodecision.com</a>&gt;  wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Yes of course ...<br>
&gt;&gt; &gt;&gt; Simpler this way ...<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; ----- Original Message -----<br>
&gt;&gt; &gt;&gt; From: &quot;Wolfgang Laun&quot;&lt;  <a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;<br>
&gt;&gt; &gt;&gt; To: &quot;Rules Users List&quot;&lt;  <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Sent: Mercredi 6 Juin 2012 18:02:40<br>
&gt;&gt; &gt;&gt; Subject: Re: [rules-users] Initial rule delay<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Try:<br>
&gt;&gt; &gt;&gt; timer( int:&lt;initial&gt;  0 )<br>
&gt;&gt; &gt;&gt; -W<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On 06/06/2012, Paul R.&lt;  <a href="mailto:reverselogic@gmail.com" target="_blank">reverselogic@gmail.com</a>&gt;  wrote:<br>
&gt;&gt; &gt;&gt;&gt; Hi,<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; I&#39;m looking for a way to delay a rules initial execution? In the<br>
&gt;&gt; &gt;&gt;&gt; following<br>
&gt;&gt; &gt;&gt;&gt; example, I would like to prevent the rule from firing when the first<br>
&gt;&gt; &gt;&gt;&gt; &quot;Foo&quot;<br>
&gt;&gt; &gt;&gt;&gt; event is inserted into the working memory.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; rule &quot;DelayTest&quot; when $n : Number() from accumulate( $f : Foo() over<br>
&gt;&gt; &gt;&gt;&gt; window:time(10s) count($f) ) then // bla end<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; The timer attribute seems to almost support what I&#39;m looking for,<br>
&gt;&gt; &gt;&gt;&gt; i.e.<br>
&gt;&gt; &gt;&gt;&gt; it<br>
&gt;&gt; &gt;&gt;&gt; allows for an initial-delay to be specified; but if the repeat<br>
&gt;&gt; &gt;&gt;&gt; interval<br>
&gt;&gt; &gt;&gt;&gt; is<br>
&gt;&gt; &gt;&gt;&gt; omitted, it uses the initial delay as the repeat interval.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; timer ( int:&lt;initial delay&gt;  &lt;repeat interval&gt;? )<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; In my case I would like to block the execution of the rule for an<br>
&gt;&gt; &gt;&gt;&gt; &quot;initial-delay&quot; period, but after that time has elapsed the rule<br>
&gt;&gt; &gt;&gt;&gt; should<br>
&gt;&gt; &gt;&gt;&gt; fire when every time a new &quot;Foo&quot; event is inserted into the working<br>
&gt;&gt; &gt;&gt;&gt; memory.<br>
&gt;&gt; &gt;&gt;&gt; What is the recommended way to do this?<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Thanks&amp;  Regards,<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Paul<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; rules-users mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; rules-users mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; rules-users mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; rules-users mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; rules-users mailing list<br>
&gt;&gt; &gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;<br>
&gt;<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>