消息边界事件
- 消息边界事件
- 一、定义
- 1. 图形标记
- 2. 设置消息 选择消息
- 3. XML标记
- 二、测试用例
- 2.1 定时边界事件xml文件
- 2.2 消息边界事件测试用例
- 总结
消息边界事件
一、定义
接收到消息触发事件
1. 图形标记
2. 设置消息 选择消息
3. XML标记
定时边界事件的XML
<message id="themessage" name="消息名称" />
<boundaryEvent id="Event_1en1iso" attachedToRef="ae85963df46bb4ea68b5d8e90473b2685">
<messageEventDefinition messageRef="themessage" />
</boundaryEvent>
二、测试用例
2.1 定时边界事件xml文件
<?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: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" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://flowable.org/bpmn">
<message id="themessage" name="消息名称" />
<process id="MessageBoundaryEventProcess" name="边界消息事件" isExecutable="true">
<startEvent id="a6511a3eab1f245eca4f207554c023df8" />
<userTask id="ae85963df46bb4ea68b5d8e90473b2685" name="触发消息任务">
<extensionElements>
<flowable:formData />
<flowable:assigneeType>static</flowable:assigneeType>
</extensionElements>
</userTask>
<sequenceFlow id="a31087c6d2a4346d18d4bff883fa2bcf6" sourceRef="a6511a3eab1f245eca4f207554c023df8" targetRef="ae85963df46bb4ea68b5d8e90473b2685" />
<userTask id="Activity_0398jsd" name="任务审批">
<extensionElements>
<flowable:formData />
<flowable:assigneeType>static</flowable:assigneeType>
</extensionElements>
</userTask>
<sequenceFlow id="Flow_1dkjedz" sourceRef="ae85963df46bb4ea68b5d8e90473b2685" targetRef="Activity_0398jsd" />
<endEvent id="Event_1twmoxj" />
<sequenceFlow id="Flow_0dfsbpm" sourceRef="Activity_0398jsd" targetRef="Event_1twmoxj" />
<boundaryEvent id="Event_1en1iso" attachedToRef="ae85963df46bb4ea68b5d8e90473b2685">
<messageEventDefinition messageRef="themessage" />
</boundaryEvent>
<userTask id="Activity_08x3p17" name="申请任务">
<extensionElements>
<flowable:formData />
<flowable:assigneeType>static</flowable:assigneeType>
</extensionElements>
</userTask>
<sequenceFlow id="Flow_0766bsk" sourceRef="Event_1en1iso" targetRef="Activity_08x3p17" />
<sequenceFlow id="Flow_1bds9sh" sourceRef="Activity_08x3p17" targetRef="Event_1twmoxj" />
</process>
2.2 消息边界事件测试用例
ProcessDefinition processDefinition = this.deployByModelKey("MessageBoundaryEventProcess");
//启动两个流程实例
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
log.info("流程实例的编号为:{}", processInstance.getId());
Task task = taskService.createTaskQuery().processDefinitionId(processDefinition.getId()).singleResult();
log.info("第1个流程实例当前所在用户任务为:{}", task.getName());
//将实例一进行
Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(processInstance.getProcessInstanceId())
.messageEventSubscriptionName("消息名称").singleResult();
//发送触发消息任务消息
runtimeService.messageEventReceived("消息名称", execution.getId());
log.info("发送触发消息任务完成");
//根据流程定义查询任务
List<Task> tasks = taskService.createTaskQuery().processDefinitionId(processDefinition.getId()).list();
for (Task t : tasks) {
log.info("编号为{}的流程实例当前所在用户任务为:{}", t.getProcessInstanceId(), t.getName());
}
总结
消息边界事件依然和上面几个边界事件一样,分中断和非中断
欢迎加入QQ群学习交流:582010059