Exclusive Gateway

An exclusive gateway (aka XOR-gateway) allows to make a decision based on data (i.e. on workflow instance variables).

workflow

If an exclusive gateway has multiple outgoing sequence flows then all sequence flows, except one, must have a conditionExpression to define when the flow is taken. The gateway can have one sequence flow without conditionExpression which must be defined as the default flow.

When an exclusive gateway is entered then the conditionExpressions are evaluated. The workflow instance takes the first sequence flow that condition is fulfilled.

If no condition is fulfilled then it takes the default flow of the gateway. In case the gateway has no default flow, an incident is created.

An exclusive gateway can also be used to join multiple incoming flows to one, in order to improve the readability of the BPMN. A joining gateway has a pass-through semantic. It doesn't merge the incoming concurrent flows like a parallel gateway.

Conditions

A conditionExpression defines when a flow is taken. The expression can access the workflow instance variables and compare them with literals or other variables. Comparisons can be combined with logical operators.

For example:

totalPrice > 100

order.customer == "Paul"

orderCount > 15 || totalPrice > 50

Additional Resources

XML representation

An exclusive gateway with two outgoing sequence flows:

<bpmn:exclusiveGateway id="exclusiveGateway" default="else" />

<bpmn:sequenceFlow id="priceGreaterThan100" name="totalPrice &#62; 100" 
  sourceRef="exclusiveGateway" targetRef="shipParcelWithInsurance">
  <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">
    <![CDATA[ totalPrice > 100 ]]>
  </bpmn:conditionExpression>
</bpmn:sequenceFlow>

<bpmn:sequenceFlow id="else" name="else" 
  sourceRef="exclusiveGateway" targetRef="shipParcel" />

Using the BPMN modeler

Adding an exclusive gateway with two outgoing sequence flows:

exclusive-gateway

Workflow Lifecycle

Workflow instance records of an exclusive gateway:

Intent Element Id Element Type
ELEMENT_ACTIVATING shipping-gateway EXCLUSIVE_GATEWAY
ELEMENT_ACTIVATED shipping-gateway EXCLUSIVE_GATEWAY
ELEMENT_COMPLETING shipping-gateway EXCLUSIVE_GATEWAY
ELEMENT_COMPLETED shipping-gateway EXCLUSIVE_GATEWAY
SEQUENCE_FLOW_TAKEN priceGreaterThan100 SEQUENCE_FLOW

References: