JavaDelegate: When executor_lockTimeInMillis isn't long enough, task gets retried

We’ve set up executor_lockTimeInMillis to some value. Using JavaDelegate we send tasks to get processed by our service. Sometimes, some tasks need longer to get executed than what the value of lockTimeInMillis is set to and Camunda starts the execution of that same task again since it didn’t get a response in a timely fashion. This results in that same task being executed in parallel.

Depending on the data we have stored, some tasks can take quite long to execute and the only solution we’ve found thus far is to set lockTimeInMillis to a ridiculously long time. But then what if there happens to be a task that takes longer to execute still?

I’d say our biggest issue is that these retries happen infinitely. If our task has no chance of being completed in the provided lockTimeInMillis value, Camunda will keep sending that same task to execution whenever the lock expires, this service task for the given process instance won’t have a chance of getting completed and we’ll have an ever-increasing number of tasks running in parallel if the disparity between time needed for the task to complete and lock time is high enough.

Any ideas how to solve this? It would probably be ideal if we could dynamically extend lock for a given task instance from our service, once we know what we’re dealing with. Also, can we stop Camunda from calling execute after certain number of retries?

Yes, this is how camunda works. IMO it’s not a very good idea to block the thread for a long time. If your service can take really long to complete and you can’t even estimate the upper bound then why don’t you do an asynchronous service out of it, i.e. you send the request first and then wait for the response in a receive event where you can spend as long as you (or the service) need.

Technically speaking, the service would call your process application to deliver the result. Hence you’ll have to implement an end point or the like. This is the downside of this solution.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.