Hello,
i’am trying to understand the behaviour of asynchronous tasks. I have already read the transaction section in the Camunda docs. This is my simple process with one asychronous service task: asynchron_test.bpmn (4.1 KB). I’am testing the process behaviour in a Unit-Test (Standard H2 Database). After the asynchronous service task started, i can not receive any process instance’s tasks. This is my testing code:
@Test
@Deployment(resources = {"asynchron_test.bpmn"})
public void testHappyPath() throws InterruptedException {
final String asynchronProcessKey = "asynchronTestProcessKey";
ProcessInstance piAsynch = processEngine().getRuntimeService().startProcessInstanceByKey(asynchronProcessKey);
Map<String, Object> variables = processEngine().getRuntimeService().getVariables(piAsynch.getId());
// once i define the service task as asynchronous, the taskList is empty.
// In synchronous mode it is working well and i receive the "Say hello" task.
// Despite the fact the service task is asynchronous I'am expecting one task in the list.
List<Task> tasks = processEngine().getTaskService().createTaskQuery().processInstanceId(piAsynch.getId()).list();
This is my delegation code:
public class SomeLongTaskDelegate implements JavaDelegate{
@Override
public void execute(DelegateExecution execution) throws Exception {
Thread.sleep(6000);
execution.setVariable("var1","hello");
}
}
Now i have the following questions:
- Why i’am not able to receive the task after the service is called asynchronously? Is this the behaviour you are expecting?
- I have understood, that you can influence the transaction’s behaviour with “asynchronous Before/After”. What is the meaning of the “exclusive” checkbox in the Camunda-Modeler? it appears, if you mark an service task as asynchronous.
I would be really grateful for your help.
Thanks a lot!