Control duration of External Task timer event from External Task listener method (start event)

In my process model I have External Tasks with timer events attached, so that they expire after a certain amount of time. The duration of a timer is determined by the value of a process variable etTimerDuration (defined in Timer Definition field of the timer event). In general that works fine so that the External Task is quit after the time in the etTimerDuration process variable expired.

Now I would like to set individual timer durations for each External Task in my process model. I figured I could just change the value of the etTimerDuration process variable in the start event listener method of each External Task and the timer event would pick it up to expire after the custom duration expired. Unfortunately (for me) the value in etTimerDuration process variable is picked up and applied to the timer event before the start event listener method is called; so I’m not able to set the value of the timer duration from from within the External Task (which kind of makes sense, I have to admit).

Any ideas how to solve my problem?

Hi @Esche,

you could either intoduce a service or script task before the external task named ‘calucate expiry date’ or use a process listener, if you know the date when the process starts.

It could (technically) be an end listener on the task before, but It’s a kind of information hiding, as nobody would exprect it there.

Hope this helps, Ingo

Thank you, @Ingo_Richtsmeier.

I was considering something in that direction, but was hoping I wouldn’t have to clutter the BPMN model with this.


Actually I realized that I could add the setting of the timer duration defining process variable in the take listener of the SequenceFlow that leads into the External Task. Still not optimal, but at least not causing BPMN clutter. (And I’ll promise to put a big comment into the External Task start listener method to express where the timer duration process variable set for this External Task! :wink: )

What is a bit confusing for me is that if I set up the take listener for the SequenceFlow, I don’t get the notify() method called for the SequenceFlow id, but for the Gateway from where the SequenceFlow starts.

Any idea why that is? Using Camunda 7.8.