[rules-dev] timer and repeat limit

Wolfgang Laun wolfgang.laun at gmail.com
Tue Oct 5 07:54:33 EDT 2010


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++;
        ...
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20101005/17a30054/attachment.html 


More information about the rules-dev mailing list