Using Camunda process engine, about the use of Parallel Gateway

When using the open source camunda process engine for secondary development, the gateway must be contacted. Camunda's Modeler tool provides four types of gateways: Exclusive Gateway, Parallel Gateway, Inclusive Gateway and event based gateway. Each gateway has its own unique functions. This article will first introduce 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.

The general meaning is:

The functions of the parallel gateway are based on incoming and outgoing sequence flows:

  • Fork: all outgoing sequence flows follow in parallel, creating a concurrent execution for each sequence flow.

  • Connection: all concurrent executions arriving at the parallel gateway wait at the gateway until the execution of each incoming sequence stream arrives. Then the process continues through the connection 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.

Important note: an important difference from other gateway types is that parallel gateways do not evaluate conditions. If conditions are defined on a sequence stream connected to a parallel gateway, they are ignored. Therefore, the most important function of parallel gateway is connection.

Process instance

Scenario: there is a leave process in the company. First, it is approved by the team leader, then by the manager and personnel. It will not end until it is approved.

Leave flow chart:

The parallel gateway does not need to configure the parameters of the nodes, but does the direct deployment test.

BPMN process model file:

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <bpmn:process id="Process_0d8i21k" name="Parallel gateway example" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_1dx1ok0</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:parallelGateway id="Gateway_1vx1coa">

      <bpmn:incoming>Flow_0l0abn3</bpmn:incoming>

      <bpmn:outgoing>Flow_18egz2b</bpmn:outgoing>

      <bpmn:outgoing>Flow_0oed7gb</bpmn:outgoing>

    </bpmn:parallelGateway>

    <bpmn:sequenceFlow id="Flow_1dx1ok0" sourceRef="StartEvent_1" targetRef="Activity_1dut7sm" />

    <bpmn:endEvent id="Event_0rb2ozq">

      <bpmn:incoming>Flow_0ipw6rw</bpmn:incoming>

    </bpmn:endEvent>

    <bpmn:userTask id="Activity_1dut7sm" name="Group leader approval">

      <bpmn:incoming>Flow_1dx1ok0</bpmn:incoming>

      <bpmn:outgoing>Flow_0l0abn3</bpmn:outgoing>

    </bpmn:userTask>

    <bpmn:userTask id="Activity_1kl1xky" name="Personnel approval">

      <bpmn:incoming>Flow_0oed7gb</bpmn:incoming>

      <bpmn:outgoing>Flow_0ww5lb2</bpmn:outgoing>

    </bpmn:userTask>

    <bpmn:userTask id="Activity_0072g8y" name="Manager approval">

      <bpmn:incoming>Flow_18egz2b</bpmn:incoming>

      <bpmn:outgoing>Flow_0aystu5</bpmn:outgoing>

    </bpmn:userTask>

    <bpmn:sequenceFlow id="Flow_0l0abn3" sourceRef="Activity_1dut7sm" targetRef="Gateway_1vx1coa" />

    <bpmn:parallelGateway id="Gateway_0xd48it">

      <bpmn:incoming>Flow_0aystu5</bpmn:incoming>

      <bpmn:incoming>Flow_0ww5lb2</bpmn:incoming>

      <bpmn:outgoing>Flow_0ipw6rw</bpmn:outgoing>

    </bpmn:parallelGateway>

    <bpmn:sequenceFlow id="Flow_18egz2b" sourceRef="Gateway_1vx1coa" targetRef="Activity_0072g8y" />

    <bpmn:sequenceFlow id="Flow_0oed7gb" sourceRef="Gateway_1vx1coa" targetRef="Activity_1kl1xky" />

    <bpmn:sequenceFlow id="Flow_0aystu5" sourceRef="Activity_0072g8y" targetRef="Gateway_0xd48it" />

    <bpmn:sequenceFlow id="Flow_0ww5lb2" sourceRef="Activity_1kl1xky" targetRef="Gateway_0xd48it" />

    <bpmn:sequenceFlow id="Flow_0ipw6rw" sourceRef="Gateway_0xd48it" targetRef="Event_0rb2ozq" />

  </bpmn:process>

  <bpmndi:BPMNDiagram id="BPMNDiagram_1">

    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0d8i21k">

      <bpmndi:BPMNEdge id="Flow_1dx1ok0_di" bpmnElement="Flow_1dx1ok0">

        <di:waypoint x="148" y="210" />

        <di:waypoint x="250" y="210" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge id="Flow_0l0abn3_di" bpmnElement="Flow_0l0abn3">

        <di:waypoint x="350" y="210" />

        <di:waypoint x="455" y="210" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge id="Flow_18egz2b_di" bpmnElement="Flow_18egz2b">

        <di:waypoint x="480" y="185" />

        <di:waypoint x="480" y="120" />

        <di:waypoint x="580" y="120" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge id="Flow_0oed7gb_di" bpmnElement="Flow_0oed7gb">

        <di:waypoint x="480" y="235" />

        <di:waypoint x="480" y="280" />

        <di:waypoint x="580" y="280" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge id="Flow_0aystu5_di" bpmnElement="Flow_0aystu5">

        <di:waypoint x="680" y="120" />

        <di:waypoint x="770" y="120" />

        <di:waypoint x="770" y="185" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge id="Flow_0ww5lb2_di" bpmnElement="Flow_0ww5lb2">

        <di:waypoint x="680" y="280" />

        <di:waypoint x="770" y="280" />

        <di:waypoint x="770" y="235" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge id="Flow_0ipw6rw_di" bpmnElement="Flow_0ipw6rw">

        <di:waypoint x="795" y="210" />

        <di:waypoint x="902" y="210" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNShape id="Activity_1kl1xky_di" bpmnElement="Activity_1kl1xky">

        <dc:Bounds x="580" y="240" width="100" height="80" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Activity_0072g8y_di" bpmnElement="Activity_0072g8y">

        <dc:Bounds x="580" y="80" width="100" height="80" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_19csdge_di" bpmnElement="Gateway_1vx1coa">

        <dc:Bounds x="455" y="185" width="50" height="50" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">

        <dc:Bounds x="112" y="192" width="36" height="36" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Activity_1dut7sm_di" bpmnElement="Activity_1dut7sm">

        <dc:Bounds x="250" y="170" width="100" height="80" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Event_0rb2ozq_di" bpmnElement="Event_0rb2ozq">

        <dc:Bounds x="902" y="192" width="36" height="36" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_035arq3_di" bpmnElement="Gateway_0xd48it">

        <dc:Bounds x="745" y="185" width="50" height="50" />

      </bpmndi:BPMNShape>

    </bpmndi:BPMNPlane>

  </bpmndi:BPMNDiagram>

</bpmn:definitions>

Deploy process and test validation

After the process is initiated, the first node is approved by the team leader.

The parallel gateway does not need to configure parameters. Even if it is configured, it will be ignored. Therefore, after directly completing this node, the tasks of manager approval and personnel approval will be generated at the same time

  

After these two tasks are generated, only these two tasks have been completed, and the process will go to the end node.

That's all for the parallel gateway. The next article is about the inclusive gateway

Keywords: Spring Boot Activiti

Added by breath18 on Thu, 03 Mar 2022 06:19:05 +0200