Best way to "recalculate" a timer

Hi,

we have the need to sometimes recalculate waiting timers, means that it can happen that the duedate should be changed. (The duedate gets calculated by some delegate class)

Currently we achieve this by using the modification api. We just cancel the timer and start the process before the timer, so the duedate gets recalculated and we have a new timer job with the valid duedate.

Is there maybe some better way to to this?

Background: I’ve now some cases where I’ve created a second token because of this modification …

Regards,
Patrick

1 Like

Is the recalculation the result of some “business event”? What if you just include that event in your process model and make the recalculation explicit? LIke this:

Cheers,
Stefan

1 Like

The recalculation could happen after some kind of business event, but it should be done “automatically” without changing the bpm models. (We have a service which queries all activities of a process and recalculates active timers)

Hi,
IMHO a timer is a process model construct whose meaning should be interpreted as this timer event will not happen before the indicated time. Hence if this principle holds, then only the process should modify timers. Hence something like Stefan’s model seems appropriate.

If you need to modify multiple timers within a process or across multiple processes, perhaps the approach taken by Stefan in conjunction with a signal event could be appropriate…

Regards

Rob

Assuming you can identify the job you want to update, is ManagementService#setJobDuedate sufficient?

1 Like

Hi Thorben,

this sounds good, I’ve now verified if we can go this way.

But sadly it’s not so easy. To calculate the new date I need to execute the timer expression, where we have a lot of different implementations. In our service, we don’t know what kind of expression was used for the current timer.

Sure, we could parse the BPM to get the expression, but then we still have the problem that we don’t have a command context / execution which can we pass to the expression.

The best solution would be a camunda service which really again evaluates the timer expression and refreshes the duedate … but I think such kind of service doesn’t exist, right?

Do you have some other Idea how we can solve this kind of problem?

Cheers,
Patrick

Hi @patrick.schalk were you to able to solve your problem? Could you please share how you implemented timer reconfiguration.

Hi!

Yes I was able to solve this, but with camunda 7.11, they will provide a new method on ManagementService for this. :wink: So maybe you just wait for the release. :smiley:

=> https://app.camunda.com/jira/browse/CAM-9685

(They use the same solution for the recalculation, just have a look at the commits)

Thanks @patrick.schalk for the useful info. I was actually looking for a way to align timer events with business days/hours. It would be really helpful if you can help me with some pointers in this regard.

1 Like