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