I have following simple bpmn xml,
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://www.flowable.org/processdef">
<process id="testify" name="testifier" isExecutable="true">
<startEvent id="start"/>
<sequenceFlow sourceRef="start" targetRef="task1"/>
<serviceTask id="task1" name="tasker 1" flowable:async="true" flowable:triggerable="false" flowable:class="ws.flowable.Class1">
</serviceTask>
<sequenceFlow sourceRef="task1" targetRef="task2"/>
<serviceTask id="task2" name="tasker 2" flowable:async="true" flowable:triggerable="false" flowable:class="ws.flowable.Class1">
</serviceTask>
<sequenceFlow sourceRef="task2" targetRef="usTask1"/>
<userTask id="usTask1" flowable:async="true"/>
<sequenceFlow sourceRef="usTask1" targetRef="end"/>
<endEvent id="end"/>
</process>
</definitions>
My execute() method of Java Delegate Class1 looks like,
public void execute(DelegateExecution execution) {
//sleeping for 10 secs to learn the behaviour
Thread.sleep(10000);
}
- I binded an ActivityStartListener to the process engine for the FlowableEngineEventType = ACTIVITY_STARTED
- When I triggered the process, why did my ActivityStartListener executed after execute() method is finished for serviceTask with id = task1? Same happened for task2 as well. Only after 10 secs , ActivityStartListener onEvent() method is called.
By the way, My Flowable ProcessEngine creation looks like,
ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration().setDataSource(dataSource);
cfg.setAsyncExecutorActivate(true);
((ProcessEngineConfigurationImpl) cfg).setActivityBehaviorFactory(new DefaultActivityBehaviorFactory(classDelegateFactory));
ProcessEngine engine = cfg.buildProcessEngine();
ActivityStartListener activityStartListener = new ActivityStartListener();
engine.getRuntimeService().addEventListener(activityStartListener, ACTIVITY_STARTED);
return engine;
ActivityStartListener should be called before calling execute() method right?