Hi, I want to use serviceTask with triggerable and async.But I don’t know how to use it, can anybody give me an example?
I’m confused:
- Why “step_one” can not be executed after startProcessInstanceByKey has been called.
- If I set “step_one” flowable:async=“false”, the execution variable is null. If set async=“true”, the execution variable is not null (code like this:)
Deployment deployment = repositoryService.createDeployment().addClasspathResource(“bpmn/SendEvent.bpmn”).deploy();
ProcessInstance pi = runtimeService.startProcessInstanceByKey(“SendEvent”);
Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(pi.getId())
.activityId(“step_one”)
.singleResult();
assertNotNull(execution);
Thread.sleep(5000);
runtimeService.triggerAsync(execution.getId());
Thread.sleep(5000);
- after triggerAsync called, nothing happened. “sendEventService.sendMessage” has been called.
My bpmn like this:
<?xml version=“1.0” encoding=“UTF-8”?>
<definitions xmlns=“http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:flowable=“http://flowable.org/bpmn” xmlns:bpmndi=“http://www.omg.org/spec/BPMN/20100524/DI” xmlns:omgdc=“http://www.omg.org/spec/DD/20100524/DC” xmlns:omgdi=“http://www.omg.org/spec/DD/20100524/DI” typeLanguage=“http://www.w3.org/2001/XMLSchema” expressionLanguage=“http://www.w3.org/1999/XPath” targetNamespace="http://www.flowable.org/processdef”>
<process id=“SendEvent” name=“SendEvent” isExecutable=“true”>
<startEvent id=“startEvent1”></startEvent>
<serviceTask id=“step_one” name=“step_one_name” flowable:async=“true” flowable:triggerable=“true” flowable:expression=“#{sendEventService.sendMessage(execution, ‘test_app’, ‘test_firstEvent’)}”></serviceTask>
<sequenceFlow id=“sid-C43EA3A5-7F38-48B8-B091-112C6632B064” sourceRef=“startEvent1” targetRef=“step_one”></sequenceFlow>
<serviceTask id=“step_two” name=“step_two_name” flowable:async=“false” flowable:triggerable=“true” flowable:expression=“#{sendEventService.sendMessage(execution, ‘test_app’, ‘test_secondEvent’)}”></serviceTask>
<sequenceFlow id=“sid-AD35CE48-AB59-4C40-9DA1-91B21F1463F9” sourceRef=“step_one” targetRef=“step_two”></sequenceFlow>
<endEvent id=“sid-FDDCC035-C01D-41D2-9867-39D78F064B50”></endEvent>
<sequenceFlow id=“sid-370A3246-FDBA-467E-86F4-BB131A80DB69” sourceRef=“step_two” targetRef=“sid-FDDCC035-C01D-41D2-9867-39D78F064B50”></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id=“BPMNDiagram_SendEvent”>
<bpmndi:BPMNPlane bpmnElement=“SendEvent” id=“BPMNPlane_SendEvent”>
<bpmndi:BPMNShape bpmnElement=“startEvent1” id=“BPMNShape_startEvent1”>
<omgdc:Bounds height=“30.0” width=“30.0” x=“100.0” y=“163.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“step_one” id=“BPMNShape_step_one”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“257.0” y=“135.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“step_two” id=“BPMNShape_step_two”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“506.0” y=“130.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“sid-FDDCC035-C01D-41D2-9867-39D78F064B50” id=“BPMNShape_sid-FDDCC035-C01D-41D2-9867-39D78F064B50”>
<omgdc:Bounds height=“28.0” width=“28.0” x=“690.0” y=“156.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement=“sid-AD35CE48-AB59-4C40-9DA1-91B21F1463F9” id=“BPMNEdge_sid-AD35CE48-AB59-4C40-9DA1-91B21F1463F9”>
<omgdi:waypoint x=“356.9499999999986” y=“173.995983935743”></omgdi:waypoint>
<omgdi:waypoint x=“505.99999999999847” y=“171.00301204819277”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“sid-370A3246-FDBA-467E-86F4-BB131A80DB69” id=“BPMNEdge_sid-370A3246-FDBA-467E-86F4-BB131A80DB69”>
<omgdi:waypoint x=“605.95” y=“170.0”></omgdi:waypoint>
<omgdi:waypoint x=“690.0” y=“170.0”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“sid-C43EA3A5-7F38-48B8-B091-112C6632B064” id=“BPMNEdge_sid-C43EA3A5-7F38-48B8-B091-112C6632B064”>
<omgdi:waypoint x=“129.9482124561182” y=“177.76565302378518”></omgdi:waypoint>
<omgdi:waypoint x=“256.9999999999982” y=“175.78046875000004”></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>