• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

使用Camunda流程引擎,并行网关Parallel Gateway使用

武飞扬头像
周周的JAVA技术栈
帮助1

在使用开源Camunda流程引擎做二次开发时,网关是必须要接触的。在Camunda的 Modeler工具中提供了4种类型的网关:Exclusive Gateway(独占网关)、Parallel Gateway(并行网关)、Inclusive Gateway(包容性网关)、Event-based Gateway(基于事件的网关),每一个网关都有自己独特的功能,这一篇就先介绍  Parallel Gateway(并行网关)。

Parallel Gateway(并行网关)

The functionality of the parallel gateway is based on the incoming and outgoing sequence flow(s):

* fork: all outgoing sequence flows are followed in parallel, creating one concurrent execution for each sequence flow.

* join: all concurrent executions arriving at the parallel gateway wait at the gateway until an execution has arrived for each of the incoming sequence flows. Then the process continues past the joining gateway.

大概意思是:

并行网关的功能基于传入和传出序列流:

  • 叉子:所有传出序列流都并行遵循,为每个序列流创建一个并发执行。

  • 连接:所有到达并行网关的并发执行都在网关等待,直到每个传入序列流的执行到达。然后这个过程继续通过连接网关。

An important difference with other gateway types is that the parallel gateway does not evaluate conditions. If conditions are defined on the sequence flow connected with the parallel gateway, they are simply ignored.

重要提醒:与其他网关类型的一个重要区别是并行网关不评估条件。如果在与并行网关连接的序列流上定义条件,则会忽略它们。所以并行网关最重要的作用是连接。

流程实例

场景:公司里有请假的流程,先是组长审批,然后是经理审批、人事审批,只有都审批通过了,才会结束。

请假流程图:

学新通

并行网关不需要对节点做参数配置,做直接部署测试。

BPMN流程模型文件:

  1.  
    <?xml version="1.0" encoding="UTF-8"?>
  2.  
    <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1yxxu28" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  3.  
     
  4.  
      <bpmn:process id="Process_0d8i21k" name="并行网关示例" isExecutable="true">
  5.  
        <bpmn:startEvent id="StartEvent_1">
  6.  
          <bpmn:outgoing>Flow_1dx1ok0</bpmn:outgoing>
  7.  
        </bpmn:startEvent>
  8.  
        <bpmn:parallelGateway id="Gateway_1vx1coa">
  9.  
     
  10.  
          <bpmn:incoming>Flow_0l0abn3</bpmn:incoming>
  11.  
     
  12.  
          <bpmn:outgoing>Flow_18egz2b</bpmn:outgoing>
  13.  
     
  14.  
          <bpmn:outgoing>Flow_0oed7gb</bpmn:outgoing>
  15.  
     
  16.  
        </bpmn:parallelGateway>
  17.  
     
  18.  
        <bpmn:sequenceFlow id="Flow_1dx1ok0" sourceRef="StartEvent_1" targetRef="Activity_1dut7sm" />
  19.  
     
  20.  
        <bpmn:endEvent id="Event_0rb2ozq">
  21.  
     
  22.  
          <bpmn:incoming>Flow_0ipw6rw</bpmn:incoming>
  23.  
     
  24.  
        </bpmn:endEvent>
  25.  
     
  26.  
        <bpmn:userTask id="Activity_1dut7sm" name="组长审批">
  27.  
     
  28.  
          <bpmn:incoming>Flow_1dx1ok0</bpmn:incoming>
  29.  
     
  30.  
          <bpmn:outgoing>Flow_0l0abn3</bpmn:outgoing>
  31.  
     
  32.  
        </bpmn:userTask>
  33.  
     
  34.  
        <bpmn:userTask id="Activity_1kl1xky" name="人事审批">
  35.  
     
  36.  
          <bpmn:incoming>Flow_0oed7gb</bpmn:incoming>
  37.  
     
  38.  
          <bpmn:outgoing>Flow_0ww5lb2</bpmn:outgoing>
  39.  
     
  40.  
        </bpmn:userTask>
  41.  
     
  42.  
        <bpmn:userTask id="Activity_0072g8y" name="经理审批">
  43.  
     
  44.  
          <bpmn:incoming>Flow_18egz2b</bpmn:incoming>
  45.  
     
  46.  
          <bpmn:outgoing>Flow_0aystu5</bpmn:outgoing>
  47.  
     
  48.  
        </bpmn:userTask>
  49.  
     
  50.  
        <bpmn:sequenceFlow id="Flow_0l0abn3" sourceRef="Activity_1dut7sm" targetRef="Gateway_1vx1coa" />
  51.  
     
  52.  
        <bpmn:parallelGateway id="Gateway_0xd48it">
  53.  
     
  54.  
          <bpmn:incoming>Flow_0aystu5</bpmn:incoming>
  55.  
     
  56.  
          <bpmn:incoming>Flow_0ww5lb2</bpmn:incoming>
  57.  
     
  58.  
          <bpmn:outgoing>Flow_0ipw6rw</bpmn:outgoing>
  59.  
     
  60.  
        </bpmn:parallelGateway>
  61.  
     
  62.  
        <bpmn:sequenceFlow id="Flow_18egz2b" sourceRef="Gateway_1vx1coa" targetRef="Activity_0072g8y" />
  63.  
     
  64.  
        <bpmn:sequenceFlow id="Flow_0oed7gb" sourceRef="Gateway_1vx1coa" targetRef="Activity_1kl1xky" />
  65.  
     
  66.  
        <bpmn:sequenceFlow id="Flow_0aystu5" sourceRef="Activity_0072g8y" targetRef="Gateway_0xd48it" />
  67.  
     
  68.  
        <bpmn:sequenceFlow id="Flow_0ww5lb2" sourceRef="Activity_1kl1xky" targetRef="Gateway_0xd48it" />
  69.  
     
  70.  
        <bpmn:sequenceFlow id="Flow_0ipw6rw" sourceRef="Gateway_0xd48it" targetRef="Event_0rb2ozq" />
  71.  
     
  72.  
      </bpmn:process>
  73.  
     
  74.  
      <bpmndi:BPMNDiagram id="BPMNDiagram_1">
  75.  
     
  76.  
        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0d8i21k">
  77.  
     
  78.  
          <bpmndi:BPMNEdge id="Flow_1dx1ok0_di" bpmnElement="Flow_1dx1ok0">
  79.  
     
  80.  
            <di:waypoint x="148" y="210" />
  81.  
     
  82.  
            <di:waypoint x="250" y="210" />
  83.  
     
  84.  
          </bpmndi:BPMNEdge>
  85.  
     
  86.  
          <bpmndi:BPMNEdge id="Flow_0l0abn3_di" bpmnElement="Flow_0l0abn3">
  87.  
     
  88.  
            <di:waypoint x="350" y="210" />
  89.  
     
  90.  
            <di:waypoint x="455" y="210" />
  91.  
     
  92.  
          </bpmndi:BPMNEdge>
  93.  
     
  94.  
          <bpmndi:BPMNEdge id="Flow_18egz2b_di" bpmnElement="Flow_18egz2b">
  95.  
     
  96.  
            <di:waypoint x="480" y="185" />
  97.  
     
  98.  
            <di:waypoint x="480" y="120" />
  99.  
     
  100.  
            <di:waypoint x="580" y="120" />
  101.  
     
  102.  
          </bpmndi:BPMNEdge>
  103.  
     
  104.  
          <bpmndi:BPMNEdge id="Flow_0oed7gb_di" bpmnElement="Flow_0oed7gb">
  105.  
     
  106.  
            <di:waypoint x="480" y="235" />
  107.  
     
  108.  
            <di:waypoint x="480" y="280" />
  109.  
     
  110.  
            <di:waypoint x="580" y="280" />
  111.  
     
  112.  
          </bpmndi:BPMNEdge>
  113.  
     
  114.  
          <bpmndi:BPMNEdge id="Flow_0aystu5_di" bpmnElement="Flow_0aystu5">
  115.  
     
  116.  
            <di:waypoint x="680" y="120" />
  117.  
     
  118.  
            <di:waypoint x="770" y="120" />
  119.  
     
  120.  
            <di:waypoint x="770" y="185" />
  121.  
     
  122.  
          </bpmndi:BPMNEdge>
  123.  
     
  124.  
          <bpmndi:BPMNEdge id="Flow_0ww5lb2_di" bpmnElement="Flow_0ww5lb2">
  125.  
     
  126.  
            <di:waypoint x="680" y="280" />
  127.  
     
  128.  
            <di:waypoint x="770" y="280" />
  129.  
     
  130.  
            <di:waypoint x="770" y="235" />
  131.  
     
  132.  
          </bpmndi:BPMNEdge>
  133.  
     
  134.  
          <bpmndi:BPMNEdge id="Flow_0ipw6rw_di" bpmnElement="Flow_0ipw6rw">
  135.  
     
  136.  
            <di:waypoint x="795" y="210" />
  137.  
     
  138.  
            <di:waypoint x="902" y="210" />
  139.  
     
  140.  
          </bpmndi:BPMNEdge>
  141.  
     
  142.  
          <bpmndi:BPMNShape id="Activity_1kl1xky_di" bpmnElement="Activity_1kl1xky">
  143.  
     
  144.  
            <dc:Bounds x="580" y="240" width="100" height="80" />
  145.  
     
  146.  
          </bpmndi:BPMNShape>
  147.  
     
  148.  
          <bpmndi:BPMNShape id="Activity_0072g8y_di" bpmnElement="Activity_0072g8y">
  149.  
     
  150.  
            <dc:Bounds x="580" y="80" width="100" height="80" />
  151.  
     
  152.  
          </bpmndi:BPMNShape>
  153.  
     
  154.  
          <bpmndi:BPMNShape id="Gateway_19csdge_di" bpmnElement="Gateway_1vx1coa">
  155.  
     
  156.  
            <dc:Bounds x="455" y="185" width="50" height="50" />
  157.  
     
  158.  
          </bpmndi:BPMNShape>
  159.  
     
  160.  
          <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
  161.  
     
  162.  
            <dc:Bounds x="112" y="192" width="36" height="36" />
  163.  
     
  164.  
          </bpmndi:BPMNShape>
  165.  
     
  166.  
          <bpmndi:BPMNShape id="Activity_1dut7sm_di" bpmnElement="Activity_1dut7sm">
  167.  
     
  168.  
            <dc:Bounds x="250" y="170" width="100" height="80" />
  169.  
     
  170.  
          </bpmndi:BPMNShape>
  171.  
     
  172.  
          <bpmndi:BPMNShape id="Event_0rb2ozq_di" bpmnElement="Event_0rb2ozq">
  173.  
     
  174.  
            <dc:Bounds x="902" y="192" width="36" height="36" />
  175.  
     
  176.  
          </bpmndi:BPMNShape>
  177.  
     
  178.  
          <bpmndi:BPMNShape id="Gateway_035arq3_di" bpmnElement="Gateway_0xd48it">
  179.  
     
  180.  
            <dc:Bounds x="745" y="185" width="50" height="50" />
  181.  
     
  182.  
          </bpmndi:BPMNShape>
  183.  
     
  184.  
        </bpmndi:BPMNPlane>
  185.  
     
  186.  
      </bpmndi:BPMNDiagram>
  187.  
     
  188.  
    </bpmn:definitions>
学新通

部署流程并测试验证

流程发起后,第一个节点是组长审批。

学新通

并行网关不需要配置参数,即使配了也会被忽略,所以直接完成此节点后,会同时产生【经理审批】、【人事审批】任务

学新通

学新通  

产生了这2个任务后,只有这2个任务都完成了此流程在会走到结束节点。

学新通

对并行网关就介绍到这里,下一篇是包容性网关介绍

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfjagcc
系列文章
更多 icon
同类精品
更多 icon
继续加载