Preventing concurrency for certain tasks?


we have several tasks which may never run in parallel depending on a topic name and a certain variable (e.g. a date).

Example: we have a TaskABC with a topic name “taskabc” and an input variable called “date” which is set to “2012-12-24”. We must prevent that a similiar task TaskABC is started with the same date, but another “TaskABC” with a date (e.g.) 2012-01-01 can start.

I have no idea how to model this in an elegant way. Any suggestions would be welcome.

Hi Chris,

I doubt that this can be expressed with BPMN, but would rather look for a technical solution. In a programming language, one would use a mutex or semaphore to limit access to a shared resource. In Camunda, you have the central database which offers locks that can serve similar purposes. For example, issuing a SELECT FOR UPDATE statement on a row that is identified by topic name and variable value would acquire an exclusive lock for the remainder of the engine transaction. All parallel transaction would block until the lock-owning transaction commits.


1 Like

Hi thorben, thank you for this idea. I think, I would prefer some kind of task (maybe a Java service task) which runs parallel or before a task and which prevents the whole process from continuing when other similiar tasks run (maybe in combination with a parallel gateway).


A radical approach could be put the task in a subprocess. Use the concatenation of task name and variable content as the business key. Enforce uniqueness on the business key. Hence creation of the subprocess will fail due to duplicate business key… Hence your calling client will need to handle the error. Also be careful if history is purged as the uniqueness constraint may be operating over a moving window. Given its a date, which is probably in the future, this may not be an issue…



1 Like