Control Process Flow with Gateways

Gateways are flow elements that define the flow of your business process. Gateways determine the path a token takes through a business process. They define control points within your business process by splitting and merging paths. When possible, gateways are used for paths that are exceptions to, or deviate from, the default path of the business process.

Exclusive Gateway: Take Only One Path (Data Condition)

The exclusive gateway lets you split your business process into two or more paths. However, the business process only continues down one of the paths even if multiple outgoing sequence flows are present. Exclusive gateways can have conditional outgoing sequence flows and must have at least one default outgoing sequence flow.

You can define expressions that are used to determine if your process continues down a conditional sequence flow. See Work with Expressions.

Evaluating the Flows of an Exclusive Gateway

When a process token reaches an exclusive gateway, the outgoing sequence flows are evaluated until one of them evaluates to True.

Exclusive Gateway icon (diamond with x sign in the middle)You can define the order in which the flows are evaluated by configuring the properties for the gateway.

  • If only one outgoing sequence flow evaluates to True, then the process token continues down that outgoing sequence flow to the next flow element.

  • If more than one outgoing sequence flow evaluates to True, then the process token continues down the first sequence flow according to the order you defined in the gateway properties.

  • If none of the outgoing sequence flows evaluates to True, then the process token moves down the default outgoing sequence flow. Therefore, you must define a default outgoing sequence flow for the exclusive gateway.

Unlike other gateways, the exclusive gateway doesn’t require a corresponding merge to be explicitly defined in your process after splitting.

Note:

The exclusive gateway can also merge incoming sequence flows. However, there’s no synchronization with other tokens that may be coming from other paths within the process flow. If other tokens arrive at an exclusive gateway merge, then they’re passed through as is. If you’re synchronizing tokens or performing evaluations on incoming sequence flows, then you should use a different type of gateway.

Example of an Exclusive Gateway

The following diagram shows an example of the exclusive gateway used within a Loan Approval business process. Here, the exclusive gateway is used to evaluate if the loan request is approved or if more information is required.

This evaluation is determined by the expression defined for the outgoing conditional sequence flow. If the expression evaluates to true, then the process flow proceeds down the No path. If it evaluates to false, then the process flow proceeds down the path of the default outgoing sequence flow.

Description of exclusive-flow.png follows
Description of the illustration exclusive-flow.png

Inclusive Gateway: Take One or More Paths

The inclusive gateway lets you split your business process into two or more paths. Unlike the exclusive gateway, however, a token may flow down one OR more of these paths depending on how the outgoing conditional sequence flows are evaluated.

The inclusive gateway requires a split-merge pair. When you add an inclusive gateway to your business process, the split and merge flow objects are automatically created:

Description of inclusive-gateway-pair.png follows
Description of the illustration inclusive-gateway-pair.png

The merge portion of the gateway is required. However, you don’t have to ensure that all paths out of the split return to the merge.

Although it’s possible to have process paths that split at a gateway without merging through the gateway, it’s not a good practice and not recommended.

Note:

If you delete the merge gateway from a business process, the corresponding split gateway is also deleted.

Splitting and Merging Inclusive Gateways

The inclusive gateway splits a business process similar to the exclusive gateway, but allows tokens to proceed down one OR more outgoing sequence flows. You can define any number of outgoing conditional sequence flows for an inclusive gateway split. You must define at least one default sequence flow.

When a token arrives at an inclusive gateway, the expressions of its conditional sequence flows are evaluated.

Next, a token is generated for each of the conditional sequence flows that evaluates to True. A token is generated for the default sequence flow only if none of the conditional sequence flows evaluate to True.

These tokens are joined at the merge of the inclusive gateway. When a token reaches the merge gateway, it waits until all the tokens generated by the split have reached the merge. After all the tokens have reached the merge of the inclusive gateway, the merge is complete, and the token continues to the next sequence flow after the gateway.

Parallel Gateway: Take All Paths Simultaneously

The parallel gateway lets you split your business process into two or more paths when you want your process flow to follow all paths simultaneously. The parallel gateway is useful when your business process must perform multiple tasks in parallel.

The parallel gateway requires a split-merge pair. When you add a parallel gateway to your business process, the split and merge flow objects are automatically created:

Description of parallel-gateway-pair.png follows
Description of the illustration parallel-gateway-pair.png

The merge portion of the gateway is required. However, you don’t have to ensure that all paths out of the split return to the merge.

Although it’s possible to have process paths that split at a gateway without merging through the gateway, it’s not a good practice and not recommended.

Note:

If you delete the merge gateway from a business process, the corresponding split gateway is also deleted.

Splitting and Merging Parallel Gateways

When a token arrives at a parallel gateway, the parallel gateway creates a token for each outgoing sequence flow. The split of the parallel gateway doesn’t evaluate any of the outgoing sequence flows.

You can also use the parallel gateway to merge process paths split by the parallel gateway. The merge of the parallel gateway waits for a token to arrive from each of the incoming sequence flows. After all tokens arrive, only one token is passed to the outgoing sequence flow.

Note:

You must design your business process so that a token arrives for each incoming sequence flow for the merging parallel gateway. If you don’t, your business process can freeze if the merge is expecting tokens that don’t arrive.

Example of a Parallel Gateway

In this example, a Sales Quote process uses a parallel gateway at the approval stage. The diagram shows how the parallel gateway is used to execute all process paths at the same time.

Description of parallel-gateway-example.png follows
Description of the illustration parallel-gateway-example.png

Event-Based Gateway: Take Only One Path (Event Occurrence)

The event-based gateway allows you to branch your process flow based on the possibility that an event may occur. Depending on the context, the event may be one of several types.

Event-based Gateway icon The event-based gateway allows you to anticipate the possibility that several types of events may occur at a specific point in your process. It's similar to the exclusive gateway, but instead of selecting a path based on data-specific conditions (expressions), the event-based gateway selects a path based on the occurrence of an event within your process.

For example, in an order processing process, you may reach a point in your process when no stock is currently available. The process may have to wait until stock is available, but can’t wait indefinitely. By using an event-based gateway, your process can wait for a message saying new stock has been received (using a message catch event) or it can continue if no message is received after a certain amount of time has passed (using a timer event).

Target Events for Event-Based Gateways

The event-based gateway is different from other gateways in that decisions about process flow are based on an event rather than data-specific conditions. For an event-based gateway, you define two or more of the following target events:

  • Message catch events: When initiating a process using a message catch event, the process must be invoked using a message throw event.

  • Timer catch events: Generally, only one timer event is used following an event-based gateway.

  • Receive tasks: You can use the receive task to initiate a process instance following an event-based gateway. However, the process must be invoked from a send task within the calling process.

Note:

You can’t mix message events and receive tasks within the same event-based gateway.

The target elements can only have incoming sequence flows from the event-based gateway. They can’t have sequence flows from other parts of the process. Although the event-based gateway allows you to plan that multiple events may occur in your process, only one event is triggered within the process instance. When the first event in the event-based gateway is triggered, the path that comes after that event is followed.

When you add an event-based gateway to a process, no associated target events are created. When you delete an event-based gateway, any outgoing sequence flows are also deleted. The associated events aren’t deleted.

Process Start with an Event-Based Gateway

You can also use an event-based gateway at the beginning of a process to create a new process instance. This is similar to having multiple start events within a process.

To allow an event-based gateway to create a new process instance:

  • You must enable the Instantiate property of the event-based gateway.

  • You can’t have any incoming sequence flows to the event-based gateway.

  • Your process must have at least one other start event, for example a message start event, in addition to the event-based gateway.

Although the event-based gateway can be used to create a new process instance, it doesn’t accept data input from another process. Any data that must be passed to the process instance must be configured using the target events.

Create a Gateway

Use gateways to control how the process flows.

To create a gateway:
  1. Open your process.
  2. In the Elements palette, click Gateways to expand the list.

    Here are the gateways you can add to a process:

    Gateway Icon Gateway Type Description

    Exclusive Gateway icon

    Exclusive

    Only one of the paths out of the gateway is taken. The decision about which path the process should proceed along is based on data-specific conditions. For example, an exclusive gateway can specify different paths for the APPROVE and REJECT outcomes of an Approval human task.

    Inclusive Gateway icon

    Inclusive

    One or more paths out of the gateway can be taken, and the paths must converge later in the process. Use this type to perform several optional or conditional tasks at the same time.

    Parallel Gateway icon

    Parallel

    All paths out of the gateway are taken, and the paths must converge later in the process. Use this type to perform several required tasks at the same time.

    Event-Based Gateway icon

    Event-Based

    Only one of the paths out of the gateway is taken. An event-based gateway is similar to an exclusive gateway because both involve one path in the flow. However, for an event-based gateway, decisions about process flow are based on an event taking place rather than a condition being met.

  3. Drag and drop the gateway element into the process flow.
  4. Select the gateway element. Click Sequence Flow Sequence Flow icon and drag the icon to create each path that exits from the gateway.
    • For exclusive or inclusive gateways, make sure the default path connects to the correct flow element. Default sequence flows represent the path your business process takes out of these gateways when none of the data conditions evaluate to true. Default sequence flows are represented by an arrow with a slash mark on one end.

    • For inclusive or parallel gateways, you can drag paths to the side to separate them.

    • For parallel gateways, you must drop at least one activity onto each path before you can create another path.

  5. For exclusive or inclusive gateways, create a data object. Data objects store and organize data the process uses.
    1. Select the gateway and click Data ObjectsData Objects icon in the toolbar. The Data Objects dialog box opens.
    2. Click Add.
    3. Type a name for this data object. All names must begin with a lowercase letter.
    4. Select the data type that matches the data flowing into the gateway from the previous task.

      In most cases, the type is boolean (true or false) or string (text). For example, select string for the APPROVE and REJECT outcomes of an Approval human task.

    5. Click Create.
    6. Close the Data Objects dialog box.
  6. For exclusive or inclusive gateways, implement each non-default path.

    You don’t need to implement the default path, but you should name it.

    1. Select a non-default path, click Edit Edit icon on the path, and click Implementation.
    2. Type a name for this path.
    3. Click Edit Edit icon next to the Condition field.
    4. Type an expression that tests whether the Gateway data object has one of the choices.
      For example, type approvalOutcome == "APPROVE". Note the double equal sign.
    5. Click OK.
    6. Close the Implementation pane.
  7. For exclusive or inclusive gateways, associate the output data with the gateway data object.
    A parallel gateway doesn’t need data association, but some of the activities on the paths might need it.
    1. Select the task that precedes and sends data to the gateway, and click Data Association in the toolbar.
    2. Expand the Process and Data Objects nodes in the right pane.
    3. Drag and drop the gateway data object into the Outputs field.

      You can associate inputs as well, which often come from a form. If the form is referenced in the start event or another process component, then the form data object appears in the right pane. Drag and drop each form field from the right pane to the corresponding Inputs field.

    4. Click Apply.
      The Data Association page closes.
  8. Click Save Save icon in the toolbar to save your changes.
For example, a process that uses exclusive gateways might look like this: