How to create asynchronous service task on Camunda

I am trying to create asynchronous service tasks, but I am not succeeding.
When I put a breakpoint on my Service A task, my Service B task does not execute because they are running on the same execution thread. How do I perform my task B independent of task A?

Log myClass execution.

Hello @Allison1,

Have you read the following documentation section?

In essence it explains how threads and the job executor work with the process instances to execute them. It also explains the default behavior of Async Service Tasks and how you could change the configuration so that you could perform task B independent of task A as per your use case.

After you’ve given it a read, please come back and let me know if you have any questions.


Hi @patozgg

I got to read the documentation but didn’t quite understand how to make it work, I’m sorry I’m new to camunda and programming. Since I’m using SpringBoot camunda, would I have to have multiple process engines to run Task A independent of Task B?

I thought that in the quote below, because I marked as exclusive, he would perform my Tasks independently of each other.

An exclusive job cannot be performed at the same time as another exclusive job from the same process instance.

I was reading this section

but I’m in doubt because I still can’t reproduce my test of running my Task A independet from Task B.

Thanks =)

Hey @Allison1,

Welcome to Camunda!

There is no need , but possible…, to have another engine to run Task A independent of Task B. In your case, it is perfectly fine to use Springboot Camunda and one engine.

So by default when you mark a Service Task as Async it is marked as Exclusive. This means that the Job Executor/Thread will try to avoid executing such Service Task in parallel as another job in the same process instance. To change this behavior you could uncheck the Exclusive check box so that the Job Executor picks up this job. This will make the Job Executor execute the Service Task even if another job of the same process instance is being executed by another thread. This would allow you to run Task A independent of Task B.

As a heads up make sure you are aware that if you uncheck the Exclusive check box you might run into Optimistic Locking Exceptions. See this forum post that references such exception. Optimistic Locking Exception will cause the Service Task to retry itself so take this into consideration when implementing your business logic.

Test this option out and please get back to me with your result.


I read through the Transaction boundaries concept in camunda Transactions in Processes |
and how to acheive it using async flags.
One point mentioned there was as soon as engine encounters a async task, the main thread terminates ( meaning the application thread triggering the process terminates) and other async tasks are pushed in queue.

What if iwant my application thread which has trigerred the process needs to wait till the completion of all async tasks and then it returns back to caller application.

In a sample workflow below, I Task B and Task C marked as async=true and not Exclusive, and Task A and Task D are not Async and i need to wait till Task D to be completed when the workflow returns back to my application in java where i have invoked it.
How will i acheive it?

stopWorkflowMidway.bpmn (10.3 KB)

1 Like