Chapter 26. Gateways
26.1. Gateways
“Gateways are used to control how Sequence Flows interact as they converge and diverge within a Process.[4]”
Gateways are used to create or synchronize branches in the workflow using a set of conditions, which is called the gating mechanism. Gateways are of two types:
- Converging, that is merging multiple flows into one flow.
- Diverging, that is splitting one Flow into multiple flows.
One Gateway cannot have multiple incoming and multiple outgoing flows.
You can use the following types of gateways:
Parallel (AND)
- Converging AND gateway waits for all incoming flows before continuing to the outgoing flow.
- Diverging AND gateway starts all outgoing flows simultaneously.
Inclusive (OR)
- Converging OR gateway waits for all incoming flows whose condition evaluates to true.
- Diverging OR gateway starts all outgoing flows whose condition evaluates to true.
Exclusive (XOR)
- Converging XOR gateway waits for the first incoming flow whose condition evaluates to true.
- Diverging XOR gateway starts only one outgoing flow.
- Data-based exclusive gateways, which can be both diverging and converging, and are used to make decisions based on available data. For further information, see Section 26.2.4, “Data-based Exclusive Gateway”.
- Event-based gateways, which can only be diverging, and are used for reacting to events. For further information, see Section 26.2.1, “Event-based Gateway”.
26.2. Gateway types
26.2.1. Event-based Gateway
“The Event-Based Gateway has pass-through semantics for a set of incoming branches (merging behavior). Exactly one of the outgoing branches is activated afterwards (branching behavior), depending on which of Events of the Gateway configuration is first triggered. [5]”
The gateway is only diverging and allows you to react to possible events as opposed to the Data-based Exclusive Gateway, which reacts to the process data. The outgoing flow is taken based on the event that occurs. Only one outgoing flow is taken at a time.
The gateway might act as a start event, where the process is instantiated only if one the intermediate events connected to the Event-Based Gateway occurs.
26.2.2. Parallel Gateway
“A Parallel Gateway is used to synchronize (combine) parallel flows and to create parallel flows.[6]”
- Diverging
- Once the incoming flow is taken, all outgoing flows are taken simultaneously.
- Converging
- The gateway waits until all incoming flows have entered and only then triggers the outgoing flow.
26.2.3. Inclusive Gateway
- Diverging
Once the incoming flow is taken, all outgoing flows that evaluate to true are taken. Connections with lower priority numbers are triggered before triggering higher priority ones. Priorities are evaluated but the BPMN2 specification does not guarantee the priority order. It is recommended that you do not depend on the
priority
attribute in your workflow.ImportantEnsure that at least one of the outgoing flow evaluates to true at runtime. Otherwise, the process instance terminates with a runtime exception.
- Converging
- The gateway merges all incoming Flows previously created by a diverging Inclusive Gateway; that is, it serves as a synchronizing entry point for the Inclusive Gateway branches.
Attributes
- Default gate
- The outgoing flow taken by default if no other flow can be taken.
26.2.4. Data-based Exclusive Gateway
- Diverging
The gateway triggers exactly one outgoing flow. The flow with the constraint evaluated to true and the lowest priority number is taken.
ImportantEnsure that at least one of the outgoing flow evaluates to true at runtime. Otherwise, the process instance terminates with a runtime exception.
- Converging
- The gateway allows a workflow branch to continue to its outgoing flow as soon as it reaches the gateway. When one of the incoming flows triggers the gateway, the workflow continues to the outgoing flow of the gateway. If it is triggered from more than one incoming flow, it triggers the next node for each trigger.
Attributes
- Default gate
- The outgoing flow taken by default if no other flow can be taken.