This works *almost* as expected:<br> timer(int: 5s 0m2s repeat-limit=10 ) <br>the exception being that the rule with this attribute fires nine times.<br>As might be expected, this one fies once:<br> timer(int: 5s 0m2s repeat-limit=2) <br>
But, surprise, surprise, these two both fires once, too:<br> timer(int: 5s 0m2s repeat-limit=1)<br> timer(int: 5s 0m2s repeat-limit=0)<br><br>I think this is due to the code in org.drools.time.impl.IntervalTrigger<br>
where the increment happens in getTimeAfter(), *before* the test<br>repeatCount >= repeatLimit; see below.<br><br> public Date nextFireTime() {<br> Date date = this.nextFireTime;<br> // FIXME: this is not safe for serialization<br>
this.nextFireTime = getTimeAfter();<br> updateToNextIncludeDate();<br> if ( this.endTime != null && this.nextFireTime.after( this.endTime ) ) {<br> this.nextFireTime = null;<br> } else if ( repeatLimit != -1 && repeatCount >= repeatLimit ) {<br>
this.nextFireTime = null;<br> }<br> return date;<br> }<br><br> private Date getTimeAfter() {<br> this.repeatCount++;<br> ...<br>}<br>