Execute service task asynchronously

Is the way to execute service task asynchronously for example somthing like this:

@Component
// code in not work because of camunda engine based on thread local context 
public class AsyncTask extends ServiceTaskJavaDelegateActivityBehavior {

    public void execute(ActivityExecution delegateExecution) throws Exception {

        CompletableFuture... //Some async operation
            .thenRunAsync(() ->this.leave(delegateExecution));
    }
}

Hi @Alexey,

please have a look at the docs how Camunda supports asynchronous continuation.

Best regards,
Philipp

you can model the activity using camunda extensions like camunda:asyncBefore or camunda:asyncAfter, it will executes the service task asynchronously by job executors

Hi i tryied make model with async before but when i start proces it always go through and its not waiting for some trigger to continue. How is it possible to stop service task and wait for some trigger to continue ?

@lianel you might need to take a look at the recieve task which is same as service task but it waits until the message is correlated (in your terms some trigger). This means that the process will stay in this wait state until a specific message is received by the engine, which triggers continuation of the process beyond the Receive Task.

https://docs.camunda.org/manual/7.12/reference/bpmn20/tasks/receive-task/

Thank you. It helped a lot.