Flowable开始事件-消息开始事件

文章目录

  • 消息开始事件
  • 一、定义
    • 1. 图形标记
    • 2. XML标记
  • 二、测试用例
    • 2.1 消息开始事件xml文件
    • 2.2 消息开始事件测试用例
  • 总结


消息开始事件


一、定义

接受特定的消息发起流程实例。

1. 图形标记

Flowable开始事件-消息开始事件_第1张图片

2. XML标记

消息开始事件的XML

  
  <message id="theMessage" name="dataReportingMessage">message>

  <process id="MessageStartEventProcess" name="消息开始事件示例流程" isExecutable="true">
    
    <startEvent id="messageStart">
    
      <messageEventDefinition messageRef="theMessage"/>
    startEvent>

二、测试用例

2.1 消息开始事件xml文件


<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: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" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">

  
  <message id="theMessage" name="dataReportingMessage">message>

  <process id="MessageStartEventProcess" name="消息开始事件示例流程" isExecutable="true">
    
    <startEvent id="messageStart">
      <messageEventDefinition messageRef="theMessage"/>
    startEvent>
    <userTask id="task1" name="数据上报">userTask>
    <endEvent id="end">endEvent>
    <sequenceFlow id="sequenceFlow1" sourceRef="task1" targetRef="end">sequenceFlow>
    <sequenceFlow id="sequenceFlow2" sourceRef="messageStart" targetRef="task1">sequenceFlow>
  process>

  <bpmndi:BPMNDiagram id="BPMNDiagram_MessageStartEventProcess">
    <bpmndi:BPMNPlane bpmnElement="MessageStartEventProcess" id="BPMNPlane_MessageStartEventProcess">
      <bpmndi:BPMNShape bpmnElement="messageStart" id="BPMNShape_messageStart">
        <omgdc:Bounds height="30.0" width="30.5" x="60.0" y="150.0">omgdc:Bounds>
      bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="task1" id="BPMNShape_task1">
        <omgdc:Bounds height="80.0" width="100.0" x="191.0" y="125.0">omgdc:Bounds>
      bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
        <omgdc:Bounds height="28.0" width="28.0" x="405.0" y="151.0">omgdc:Bounds>
      bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow1" id="BPMNEdge_sequenceFlow1">
        <omgdi:waypoint x="291.0" y="165.0">omgdi:waypoint>
        <omgdi:waypoint x="405.0" y="165.0">omgdi:waypoint>
      bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sequenceFlow2" id="BPMNEdge_sequenceFlow2">
        <omgdi:waypoint x="90.5" y="165.0">omgdi:waypoint>
        <omgdi:waypoint x="191.0" y="165.0">omgdi:waypoint>
      bpmndi:BPMNEdge>
    bpmndi:BPMNPlane>
  bpmndi:BPMNDiagram>
definitions>

2.2 消息开始事件测试用例

       ProcessDefinition processDefinition = this.deployByClasspathResource("startEvent/MessageStart1EventProcess.bpmn20.xml");
        //注意这里的messageName就是定义的消息名称非ID
        runtimeService.startProcessInstanceByMessage("dataReportingMessage");
        List<Task> list = taskService.createTaskQuery().processDefinitionId(processDefinition.getId()).list();
        if (CollectionUtils.isNotEmpty(list)) {
            list.forEach(task -> log.info("任务名称为:{}", task.getName()));
        }

总结

消息启动事件,我们可以利用mq的形式接受消息然后启动流程。

你可能感兴趣的:(Flowable组件库,java,开发语言)