Gateways

Gateways control the flow of movement in a process. They allow modeling decisions based on data and events, as well as fork/join parallelism.

../../../../../_images/gway_1.png ../../../../../_images/gway_1_1.png

Exclusive Gateway (XOR, исключающий) «either/or» — selection of only one path.

../../../../../_images/gway_2.png ../../../../../_images/gway_2_1.png

Parallel Gateway (AND), «and» — selection of all paths.

../../../../../_images/gway_3.png ../../../../../_images/gway_3_1.png

Inclusive Gateway (OR, неисключающий), «and/or» — selection of one or several.

../../../../../_images/gway_4.png ../../../../../_images/gway_4_1.png

Event-based Gateway — selection of the first event that occurs.

Selecting the gateway type:

../../../../../_images/gway_5.png

The default gateway is exclusive.

Exclusive Gateway (XOR)

Exclusive Gateway (also called XOR gateway or, more technically, data-based exclusive gateway) is used to model decisions in a process.

When process execution reaches this gateway, all outgoing sequence flows are evaluated in the order they were defined. The sequence flow whose condition evaluates to ‘true’ (or which has no condition set, conceptually having a ‘true’ value) is selected for process continuation.

Note that when using an exclusive gateway, only one sequence flow is selected. If multiple sequence flows have a condition that evaluates to ‘true’, only the first one defined in the diagram is selected for process continuation.

If a sequence flow cannot be selected (none of the conditions evaluate to ‘true’), it will result in a runtime exception if you have not defined a default flow. One default flow can be set on the gateway itself for the case where no other condition matches — similar to an ‘else’ clause in programming languages.

../../../../../_images/gway_6.png

Gateway configuration:

../../../../../_images/gway_7.png

Parallel Gateway

Parallel Gateway (also called AND gateway), which allows forking into multiple paths of process execution or merging multiple incoming paths of process execution.

The functionality of the parallel gateway is based on incoming and outgoing sequence flows:

  • forking: all outgoing sequence flows are executed in parallel, creating one parallel execution for each sequence flow.

  • joining: all concurrent executions arriving at the parallel gateway wait at the gateway until process execution has been completed for each of the incoming sequence flows. Then the process continues past the joining gateway.

Note that a parallel gateway can have both forking and joining behavior if there are multiple incoming and outgoing sequence flows for the same parallel gateway. In this case, the gateway will first join all incoming sequence flows and then split them into several parallel execution paths.

An important difference from other gateway types is that the parallel gateway does not evaluate conditions. If conditions are defined for sequence flows connected to a parallel gateway, they are simply ignored.

The actual behavior (forking, joining, or both) is determined by the sequence flows connected to the parallel gateway.

../../../../../_images/gway_8.png

Gateway configuration:

../../../../../_images/gway_9.png

Inclusive Gateway

Inclusive Gateway can be considered a combination of exclusive and parallel gateways.

Similar to the exclusive gateway, you can define conditions for outgoing sequence flows, and the inclusive gateway will evaluate them. The inclusive gateway can take more than one sequence flow, like the parallel gateway. The functionality of the inclusive gateway is based on incoming and outgoing sequence flows:

The functionality of the parallel gateway is based on incoming and outgoing sequence flows:

  • forking: all outgoing sequence flow conditions are evaluated, and for sequence flow conditions that evaluate to ‘true’, the flows are executed in parallel, creating one parallel execution for each sequence flow.

  • joining: all concurrent executions arriving at the inclusive gateway wait at the gateway until process execution has occurred for each of the incoming sequence flows that have a process token. This is an important difference from the parallel gateway. In other words, the inclusive gateway will only wait for the execution of incoming sequence flows that are active. After joining, the process continues past the inclusive joining gateway.

Note that an inclusive gateway can operate with both forking and joining if there are multiple incoming and outgoing sequence flows for the same inclusive gateway. In this case, the gateway will first join all incoming sequence flows that have a process token, and then split them into several parallel process execution paths for outgoing sequence flows whose condition evaluates to ‘true’.

The actual behavior (forking, joining, or both) is determined by the sequence flows connected to the inclusive gateway.

../../../../../_images/gway_10.png

Gateway configuration:

../../../../../_images/gway_11.png

Event-based

Event-based Gateway allows making decisions based on events.

Each outgoing sequence flow of the gateway must be connected to an Intermediate Catch Event. When process execution reaches the event-based gateway, the gateway enters a wait state: process execution is suspended. Additionally, an event subscription is created for each outgoing sequence flow.

../../../../../_images/gway_12.png

Note that the sequence flows exiting an event-based gateway are different from regular sequence flows. These sequence flows are never actually ‘executed’. Instead, they allow the process engine to determine which events the process execution arriving at the event-based gateway should subscribe to.

The following constraints apply:

  • The gateway must have two or more outgoing sequence flows.

  • Only elements of type Intermediate Catch Event can follow the gateway (Receiving tasks after an event-based gateway are not yet supported by the engine.)

  • The Intermediate CatchEvent connected to the gateway must have one incoming sequence flow.

../../../../../_images/gway_13.png

Gateway configuration:

../../../../../_images/gway_14.png

The process is an example of a process with an event-based gateway. When execution reaches the event-based gateway, process execution is suspended. Additionally, the process instance subscribes to a warning signal event and creates a timer that fires after 10 minutes. This effectively causes the process engine to wait for a signal event for ten minutes. If the signal event occurs within 10 minutes, the timer is canceled and execution continues after the signal. If the signal is not triggered, execution continues after the timer, and the signal subscription is canceled.

A comparison of gateways is presented in the table:

Gateway Type

Splitting

Merging

Conditions

Exclusive

One branch

Passes flow immediately

Yes (selects one branch)

Parallel

All branches

Waits for all branches to complete

No

Inclusive

Multiple branches (based on conditions)

Waits for active branches to complete

Yes (multiple conditions)

Event-based

Based on events

Not required (waits for first event)

No (reacts to events)