Hi @Jana
Welcome to the forum :camunda:
So this is actually by design, I’ll try to explain whats happening and then try to work out what exactly you need to do and then hopefully find a solution for you.
There are some fundamentals about the engine which need to be remembered when trying to understand how certain interactions like this take place.
- A single process instance should never have more than one thread working on it at any one time. (to ensure the state does not get corrupted)
- The process engine will never interrupt a running thread - it will always let the tread finish before assessing the state of the process.
So what’s happening here is that
- The tread reaching the service task and commits to the database the timer event.
- The tread then runs the java class - which exceeds the timer
a. The timer is only checked when the tread comes to a wait state so it’s not triggered. - The thread finishes running the code and moves on to the gateway.
a. As soon as the Thread leaves the service task the timer is now out of scope and so will never trigger.
This is why it works on a user task - because with a user task there is not active thread on the process instance and so the timer can easily interrupt the task.
So this brings me to the next question - what exactly is the end goal you’re trying to reach?
Are you trying to set the limit on the time a service task will run?