Hi!
I wonder if there is a possibility to customize the way Camunda acquires or executes new jobs.
In my process, I have multiple processes with async tasks running at the same time. Sometimes, different tasks try to update the same entity in the database at the same time. I would like to avoid this by running new tasks by conditions, e.g.
“Camunda should skip running a task if there is already another running task related to the same entity (e.g. having a process variable orderId
). After that task has been completed, Camunda can execute the previously skipped task”.
Thank you in advance,
Vadzim.
Hi Vadzim,
You can implement org.camunda.bpm.engine.impl.jobexecutor.AcquireJobsCommandFactory
to provide a custom command for job acquisition. This command is called whenever the job executor decides to acquire jobs. You can plug that into the job executor by calling JobExeuctor#setAcquireJobsCmdFactory
before you start it.
Cheers,
Thorben
@thorben , thanks for your answer!
However, I’m not sure how I can access the currently running processes from that factory and filter the next jobs by a process variable (“orderId” in my case).
The default implementation of that factory just creates a new AcquireJobsCmd
that, in turn, uses a JobManager
that, in turn, finds jobs using a Page
.