Unclear on semantics of exclusive attribute

I am unclear on exactly how exclusive works for parallel tasks. My original use case involves dealing with two events that arrive simultaneously each of which modifies the user task that the events were attached to. I was getting an optimistic locking exception (which seemed reasonable). My attempt to fix this was to put all the processing for each of the events in a subprocess and make that sub process async before and exclusive. I thought this would serialize the two paths. HOwever it does not seem that it does. So I started doing some testing on what effect the exclusive flag has. I set up a simple dummy process as shown in the attached diagram.

Each of the parallel subprocesses are marked as async before and exclusive. I assumed that this would not let them both run at the same time but what I see is that tokens reach the timers in both subprocesses concurrently. What I was expecting was that one subprocess would finish before the other started. Any insight as to what I am missing on how exclusive works would be greatly appeciated. Also if anyone has advice as to how to avoid the optimistic locking exception I get when two events that modify the same user task are received at the same time would also be greatly appreciated

Hi @bills,

you can find more background information about exclusive jobs here: The Job Executor | docs.camunda.org

The exclusive check assures, that during job acquisition only a single job of a process instances is acquired and executed. The next job of the process instance will be started in the next acquisition round. It depends on the runtime of the job, if they overlap (most probably) or not (if the first job gets executed very fast).

Hope this helps, Ingo

I’m not sure about that. My understanding of the docs is that a next exclusive job is executed only after the previous one has been completed (since they get dispatched to the same thread) so that no job overlapping should occur.

Or do you think that the overlapping can occur if there are multiple nodes?

Hi @fml2,

with the exclusive flag, the jobs are not started at the same time in the same acquisition round. The job execution depends on the size of the thread pool.

If you have a big enough pool and a small enough acquisition number, it can occur, that several jobs of a single process instance can overlap.

Hope this helps, Ingo