文章目录
1. 结束事件
版权声明:本文部分为CSDN博主「司马缸砸缸了」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接
1.1 简介
结束事件都是触发事件。 这是说当流程达到结束事件,会触发一个结果。
分为无指定结束事件,错误结束事件,取消结束事件,终止结束事件等。
2. 错误结束事件
2.1 简介
当流程到达错误结束事件时会结束执行流并且抛出错误,该错误可以被错误边界事件捕获,如果没有被捕获,那么他就相当于无指定结束事件。一般用在子流程中。
2.2 流程设计
流程文件bpmn
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.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" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1596088558202" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<error errorCode="error" id="ERR_1" name="error"/>
<process id="myProcess_1" isClosed="false" isExecutable="true" processType="None">
<startEvent id="_2" name="开始"/>
<subProcess activiti:exclusive="true" id="_3" name="子流程" triggeredByEvent="false">
<startEvent id="_5" name="开始2"/>
<userTask activiti:assignee="user1" activiti:exclusive="true" id="_6" name="服务执行"/>
<exclusiveGateway gatewayDirection="Unspecified" id="_7" name="ExclusiveGateway"/>
<endEvent id="_8" name="结束2"/>
<endEvent id="_9" name="结束3">
<errorEventDefinition errorRef="ERR_1" id="_9_ED_1"/>
</endEvent>
<sequenceFlow id="_12" sourceRef="_5" targetRef="_6"/>
<sequenceFlow id="_13" sourceRef="_6" targetRef="_7"/>
<sequenceFlow id="_14" name="无指定结束" sourceRef="_7" targetRef="_8">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${flag == false}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_15" name="错误结束" sourceRef="_7" targetRef="_9">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${flag == true}]]></conditionExpression>
</sequenceFlow>
</subProcess>
<sequenceFlow id="_4" sourceRef="_2" targetRef="_3"/>
<boundaryEvent attachedToRef="_3" cancelActivity="true" id="_10" name="错误边界事件">
<errorEventDefinition errorRef="ERR_1" id="_10_ED_1"/>
</boundaryEvent>
<userTask activiti:assignee="user2" activiti:exclusive="true" id="_11" name="错误任务"/>
<sequenceFlow id="_16" sourceRef="_10" targetRef="_11"/>
</process>
<bpmndi:BPMNDiagram documentation="background=#000000;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="myProcess_1">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="175.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3" isExpanded="true">
<omgdc:Bounds height="267.0" width="610.0" x="110.0" y="65.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="267.0" width="610.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_11" id="Shape-_11">
<omgdc:Bounds height="55.0" width="85.0" x="525.0" y="400.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_10" id="Shape-_10">
<omgdc:Bounds height="32.0" width="32.0" x="440.0" y="315.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="330.0" y="250.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
<omgdc:Bounds height="32.0" width="32.0" x="165.0" y="170.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
<omgdc:Bounds height="55.0" width="85.0" x="275.0" y="160.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7" isMarkerVisible="false">
<omgdc:Bounds height="32.0" width="32.0" x="485.0" y="170.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_8" id="Shape-_8">
<omgdc:Bounds height="32.0" width="32.0" x="620.0" y="110.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_9" id="Shape-_9">
<omgdc:Bounds height="32.0" width="32.0" x="620.0" y="240.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_6" targetElement="_7">
<omgdi:waypoint x="360.0" y="187.5"/>
<omgdi:waypoint x="485.0" y="186.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12" sourceElement="_5" targetElement="_6">
<omgdi:waypoint x="197.0" y="186.0"/>
<omgdi:waypoint x="275.0" y="187.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_15" id="BPMNEdge__15" sourceElement="_7" targetElement="_9">
<omgdi:waypoint x="517.0" y="186.0"/>
<omgdi:waypoint x="620.0" y="256.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_14" id="BPMNEdge__14" sourceElement="_7" targetElement="_8">
<omgdi:waypoint x="517.0" y="186.0"/>
<omgdi:waypoint x="620.0" y="126.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_16" id="BPMNEdge__16" sourceElement="_10" targetElement="_11">
<omgdi:waypoint x="472.0" y="331.0"/>
<omgdi:waypoint x="525.0" y="427.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_4" id="BPMNEdge__4" sourceElement="_2" targetElement="_3">
<omgdi:waypoint x="32.0" y="191.0"/>
<omgdi:waypoint x="110.0" y="198.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
2.3 测试类
package com.yb.activiti6;
import org.activiti.engine.*;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @version 1.0
* @date 2020/7/23
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class ActivitiDemoTest18 {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private IdentityService identityService;
@Autowired
private RepositoryService repositoryService;
@Autowired
private ProcessEngine processEngine;
@Autowired
private HistoryService historyService;
/**
* 发布流程,测试错误结束事件
* @throws IOException
*/
@Test
public void deploymentProcesses_zip(){
Deployment deploy = repositoryService.createDeployment()
.name("测试-错误结束事件-1")//创建流程名称
.addClasspathResource("processes/activiti_errorEnd.bpmn")//指定zip完成部署
.addClasspathResource("processes/activiti_errorEnd.png")
.deploy();
System.out.println("部署id:"+deploy.getId());
System.out.println("部署名称:"+deploy.getName());
}
/**
* 启动流程,测试错误结束事件
*/
@Test
public void startProcess(){
//可根据id,key,message启动流程
ProcessInstance msg = runtimeService.startProcessInstanceByKey("myProcess_1");
System.out.println("流程实例id:"+msg.getId());
System.out.println("流程定义id:"+msg.getProcessDefinitionId());
System.out.println("=========================================================");
List<Task> list = taskService.createTaskQuery().taskAssignee("user1").list();
for (Task task : list) {
System.out.println("任务ID:" + task.getId());
System.out.println("任务名称:" + task.getName());
System.out.println("任务创建时间:" + task.getCreateTime());
System.out.println("任务委派人:" + task.getAssignee());
System.out.println("流程实例ID:" + task.getProcessInstanceId());
//完成任务
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("flag", true);
taskService.complete(task.getId(), variables);
}
try {
// 睡一会
Thread.sleep(1000 * 3);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 查询任务
List<Task> List2 = taskService.createTaskQuery() // 创建任务查询
.taskAssignee("user2") // 指定某个人
.list();
for (Task task : List2) {
System.out.println("任务ID:" + task.getId());
System.out.println("任务名称:" + task.getName());
System.out.println("任务创建时间:" + task.getCreateTime());
System.out.println("任务委派人:" + task.getAssignee());
System.out.println("流程实例ID:" + task.getProcessInstanceId());
}
}
}
2.4 运行
运行deploymentProcesses_zip()
2.4.1 启动流程
运行startProcess(), 设置flag=true
效果
3. 终止结束事件
3.1 简介
当流程到达终止结束事件时会结束当前执行流,如果activiti:terminateAll属性设置成true,那么该流程实例的所有执行流全部终止。如可以用在子流程,嵌入式子流程,调用子流程,事务字流程中。
3.2 流程设计
终止结束事件
流程文件bpmn
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.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" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1596091132413" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="terminationEnd" isClosed="false" isExecutable="true" name="TerminationEnd" processType="None">
<startEvent id="_2" name="开始1"/>
<parallelGateway gatewayDirection="Unspecified" id="_3" name="ParallelGateway"/>
<subProcess activiti:exclusive="true" id="_4" name="子流程" triggeredByEvent="false">
<startEvent id="_8" name="开始2"/>
<serviceTask activiti:class="com.yb.activiti6.delegate.NewEndDelegate" activiti:exclusive="true" id="_9" name="服务执行"/>
<endEvent id="_10" name="结束2">
<terminateEventDefinition id="_10_ED_1"/>
</endEvent>
<sequenceFlow id="_14" sourceRef="_8" targetRef="_9"/>
<sequenceFlow id="_15" sourceRef="_9" targetRef="_10"/>
</subProcess>
<userTask activiti:assignee="user2" activiti:exclusive="true" id="_5" name="用户任务2"/>
<endEvent id="_6" name="结束1"/>
<userTask activiti:assignee="user1" activiti:exclusive="true" id="_7" name="用户任务1"/>
<sequenceFlow id="_11" sourceRef="_2" targetRef="_3"/>
<sequenceFlow id="_12" sourceRef="_3" targetRef="_4"/>
<sequenceFlow id="_13" sourceRef="_3" targetRef="_7"/>
<sequenceFlow id="_16" sourceRef="_4" targetRef="_5"/>
<sequenceFlow id="_17" sourceRef="_5" targetRef="_6"/>
<sequenceFlow id="_18" sourceRef="_7" targetRef="_5"/>
</process>
<bpmndi:BPMNDiagram documentation="background=#000000;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="terminationEnd">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="10.0" y="260.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<omgdc:Bounds height="32.0" width="32.0" x="130.0" y="260.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4" isExpanded="true">
<omgdc:Bounds height="155.0" width="470.0" x="225.0" y="75.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="155.0" width="470.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
<omgdc:Bounds height="55.0" width="85.0" x="780.0" y="245.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
<omgdc:Bounds height="32.0" width="32.0" x="955.0" y="255.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7">
<omgdc:Bounds height="55.0" width="85.0" x="425.0" y="405.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_8" id="Shape-_8">
<omgdc:Bounds height="32.0" width="32.0" x="270.0" y="140.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_9" id="Shape-_9">
<omgdc:Bounds height="55.0" width="85.0" x="420.0" y="130.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_10" id="Shape-_10">
<omgdc:Bounds height="32.0" width="32.0" x="625.0" y="135.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_3" targetElement="_7">
<omgdi:waypoint x="162.0" y="276.0"/>
<omgdi:waypoint x="425.0" y="432.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12" sourceElement="_3" targetElement="_4">
<omgdi:waypoint x="162.0" y="276.0"/>
<omgdi:waypoint x="225.0" y="152.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_15" id="BPMNEdge__15" sourceElement="_9" targetElement="_10">
<omgdi:waypoint x="505.0" y="157.5"/>
<omgdi:waypoint x="625.0" y="151.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_14" id="BPMNEdge__14" sourceElement="_8" targetElement="_9">
<omgdi:waypoint x="302.0" y="156.0"/>
<omgdi:waypoint x="420.0" y="157.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_17" id="BPMNEdge__17" sourceElement="_5" targetElement="_6">
<omgdi:waypoint x="865.0" y="272.5"/>
<omgdi:waypoint x="955.0" y="271.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_16" id="BPMNEdge__16" sourceElement="_4" targetElement="_5">
<omgdi:waypoint x="695.0" y="152.5"/>
<omgdi:waypoint x="780.0" y="272.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_18" id="BPMNEdge__18" sourceElement="_7" targetElement="_5">
<omgdi:waypoint x="510.0" y="432.5"/>
<omgdi:waypoint x="780.0" y="272.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_11" id="BPMNEdge__11" sourceElement="_2" targetElement="_3">
<omgdi:waypoint x="42.0" y="276.0"/>
<omgdi:waypoint x="130.0" y="276.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
3.3 测试类
package com.yb.activiti6;
import org.activiti.engine.*;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
/**
* @version 1.0
* @date 2020/7/23
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class ActivitiDemoTest19 {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private IdentityService identityService;
@Autowired
private RepositoryService repositoryService;
@Autowired
private ProcessEngine processEngine;
@Autowired
private HistoryService historyService;
/**
* 发布流程,测试终止结束事件
* @throws IOException
*/
@Test
public void deploymentProcesses_zip(){
Deployment deploy = repositoryService.createDeployment()
.name("测试-错误结束事件-1")//创建流程名称
.addClasspathResource("processes/activiti_terminationEnd.bpmn")//指定zip完成部署
.addClasspathResource("processes/activiti_terminationEnd.png")
.deploy();
System.out.println("部署id:"+deploy.getId());
System.out.println("部署名称:"+deploy.getName());
}
/**
* 启动流程,测试终止结束事件
*/
@Test
public void startProcess(){
//可根据id,key,message启动流程
ProcessInstance msg = runtimeService.startProcessInstanceByKey("terminationEnd");
System.out.println("流程实例id:"+msg.getId());
System.out.println("流程定义id:"+msg.getProcessDefinitionId());
System.out.println("=========================================================");
try {
// 睡一会
Thread.sleep(1000 * 3);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 查询执行流
long exeCount = runtimeService.createExecutionQuery()
.processInstanceId(msg.getId())
.count();
System.out.println("执行流数量:" + exeCount);
}
}
3.4 运行
运行deploymentProcesses_zip()
3.4.1 启动流程
运行startProcess()
当前测试,使用的是idea中的bpmn插件,无法设置activiti:terminateAll="true"属性,最终测试结果如下:
**说明:**无法设置activiti:terminateAll=“true”,该流程实例的所有执行流无法全部终止,正在寻找ideaBpmn插件该属性如何设置,之后后续在更新,如有知道该属性在该插件内如何设置,请评论留言,感谢!!!