Timer boundary event on service tasks

Hi,

I have tested timer boundary events (interrupting and
non-interrupting) on service tasks but they did not work as expected.

Does Camunda support timer boundary events on service tasks?

Best regards

Hi @tomes,

Yes, timer events are supported, see 1.

Could you please elaborate a bit more in detail what did not work for you? What did you expect and what was the actual result?

Thanks.

Cheers,
Roman

Hi @roman.smirnov

I tried boundary events on UserTasks and they work perfectly.
My question is relatet to timer boundary events on service tasks. Even if my service task takes longer then the configured duration on the timer boundary events, the service task is finished.

My expectation is that the timer event is triggered.

Hi @tomes,

Could you please share the corresponding bpmn model?

Cheers,
Roman

Hi @roman.smirnov

Does it work in your test?

Hi @tomes
Try to set camunda:asyncBefore=“true” on Service Task

See below link
https://docs.camunda.org/manual/7.5/user-guide/process-engine/transactions-in-processes/#reasoning-for-this-design

Timers cannot fire before the transaction is committed to the database. Timers are explained in more detail later, but they are triggered by the only active part of the Process Engine where we use own Threads: The Job Executor. Hence they run in an own thread which receives the due timers from the database. However, in the database the timers are not visible before the current transaction is visible.

1 Like

Hassan is correct that a timer won’t fire before it gets committed and that the process engine only commits when the process instance reaches a wait state. However, asyncBefore won’t help here since it is before and not after start. That means, when the asyncBefore job is created, the service task is not active yet and therefore the timer job does not exist yet. Timer events on service tasks will only work if the service task itself is a wait state. That is the case if it is implemented as an external task or if it is implemented via the asynchronous service task pattern.

Cheers,
Thorben

3 Likes

Hi,

Sorry for digging up an old-ish thread but I too thought I could put a timer on my service task. So I’ve taken a look at the asynchronous service task pattern (checked out the code and looked at the test) and I am wondering how a timer would work on the asynchronous service task? I went ahead and changed the diagram and added a little bit of code but I don’t think the timer gets triggered at all, just like for normal service tasks.

I had a read of the external tasks but I don’t really get where the actual work a task needs to complete is implemented.

Any help would be appreciated thank you