Avoiding OptimisticLockingException when receiving a message event during job execution

Hi, couldn’t find any similar posts, hoping to get some opinions or suggestions.

We have a sub process that handles sending and receiving responses from a third-party application asynchronously. Here’s an example:

If the message is received while executing a job, an update to the execution row in ACT_RU_EXECUTION causes an OptimisticLockingException when the job completes.

The simplest way to solve this I found was to add another layer of expanded subprocess, so the message event updates the execution scope above the current job scope, preventing the exception. Like this:

Is there a less complicated way of modeling to achieve the same thing?

We also considered setting the “responseReceived” variable directly from the controller instead of sending the message. However, this approach is problematic because if the conditional event is evaluated simultaneously as the variable is set, the condition might be evaluated as false, preventing re-evaluation upon updating the variable. This could cause the process to get stuck with the variable set as true. Is there a way to prevent this?

I’m open to any suggestions for completely redesigning this subprocess, but I would like to avoid changing the API implementations on either side. The main goal is to avoid OptimisticLockingException without increasing the DB load.


Hi @fredrikw

Try modeling it as stated in below post

If you apply the above model, do configure a savepoint before the parallel join.

Thanks for the quick answer @hassang, that works nicely. :slight_smile:

1 Like

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