22 Communicating Business Processes Using Correlations

This chapter describes how to develop a BPMN process that communicates with other BPMN processes and services using correlations. Correlations are used to identify the instance that receives the message in the peer process.

This chapter includes the following sections:

22.1 Introduction to Correlations

Correlations enable business processes to communicate with each other based on the state of an instance. The state of all the process data objects in a process defines the state of the instance.

Defining a correlation for a business process enables you to identify an instance in another process through the instance state and send a message to that specific instance.

For example you can use correlations to communicate a sales process with the corresponding shipping and mailing processes. When the customer confirms an order, the shipping process sends a message to the shipping and mailing processes using a correlation that defines that it uses the order ID to locate the instances in both processes.

After you initialize a correlation you cannot change its value because the Service Engine uses this value to locate the instance. If you try to assign a new value to the correlation this produces a Correlation ViolationError.

You can define and initialize multiple correlations for a flow object. The flow object that sends the message can use just one correlation or all the correlations defined for that flow object. If it uses all the existing correlations, then all of the values it sends together with the message must lead to the identification of the same instance.

Some flow objects, like the service task, define two types of correlations: input and output. In those cases you can initialize and use a correlation in the same activity.

The scope of the correlation is the instance of the process or subprocess where it is defined. In the case of subprocess with multi-instance loop conditions the scope of the correlation is each instance of the multi-instance subprocess.

Note:

Use correlations to communicate with a subprocess in a single flow. If the flow is parallel, then you must use conversations. For more information about conversations, see Defining Conversations.

Note:

There is no check for duplicate correlation IDs, so Oracle BPM does not throw an error during initialization if a correlation ID is already used.

22.2 Understanding the Components of a Correlation

Components of a correlation include a definition, keys, property, and property alias.

The following list describes the different components of a correlation:

  • Correlation Definition

    Contains the set of correlation keys defined for a flow object.

  • Correlation Keys

    Define the properties to use in the correlation. When you define a correlation key you provide a name to identify it. The scope of the correlation key is the project, which means that after you define a correlation key you can use it for the correlation definition of any flow object in that project.

    If your BPM project contains BPEL processes, then the correlation keys defined in that BPEL process automatically appear for you to reuse them in your BPM Projects.

  • Correlation Property

    Properties are abstractions for very representative attributes in the process, like the order ID, the customer name or the social security number. Properties contain a name to identify the attribute and a data type. Properties only support basic data types.

  • Correlation Property Alias

    Enable you to define how to assign a value to the correlation property using expressions. You can use the arguments and predefined variables of the activity to assign values to the correlation property alias.

22.3 Typical Design Workflow

This workflow describes the typical procedures you perform when you design a project that contains business processes that communicate with each other using correlations.

  1. Design the processes that communicate with each other.
  2. In the calling process, add the flow object that sends a message to the other process.
  3. Define a correlation for the flow object that sends the message and configure it to initiate the property aliases.

    For more information on how to define the correlation, see Defining Correlations for a BPMN Element.

  4. In the invoked process, add the flow object that receives the message.
  5. Configure the flow object that receives the message to use the correlation you defined and assign a value to the property aliases.

    For more information on how to define the correlation, see Defining Correlations for a BPMN Element.

22.4 Defining Correlations for a BPMN Element

You can define multiple correlations for a single flow object. The flow object that sends the message can choose to use just one correlation or use all of them. In the latter it the values it uses to invoke the correlation lead to the identification of the same instance.

You can define correlations for the following BPMN flow objects that you use to communicate business processes:

  • Message Events

  • Send and Receive Tasks

  • Signal Events

Note:

The use of a multicast subscription impacts all message based correlations. If you define a multi-cast subscription for Oracle EDN, then all message based correlations are multi-cast.

22.4.1 How to Define a Correlation for a Flow Object

You can define a correlation while you are defining the properties of a flow object. Studio provides two modes for defining correlations: simple and advanced. To define a correlation that contains just one property use the simple mode. If the correlation you define contains more that one correlation key each with multiple properties, then use advanced mode.

To define a correlation for a flow object:

  1. Right-click the BPMN element.

    The Properties dialog box appears.

  2. Click the Implementation tab.
  3. Click the Correlations link.

    The Correlation Definition dialog box appears.

  4. Define the correlation using one of the following modes:

22.4.2 How to Define a Correlation Using Simple Mode

Simple mode allows you to define a correlation that contains just one property. This mode simplifies the definition of the correlation by creating parts of the correlation automatically based on the information you define for that property.

To define a correlation using simple mode:

  1. From the Property list, select a property.

    If the Property list is empty, create a new property:

    1. Click the New button next to the Property list.

    2. Enter a name.

    3. Select a type.

      Available types are: string, int, double, decimal, boolean, time.

  2. If the BPMN element initiates the value of the correlation, select Initiates.

  3. In the Correlation Property Alias text box, define an expression to assign values to the correlation property.

    To define a complex expression, click the Expression Builder button next to the Correlation Property Alias text box. For more information see Writing Expressions.

  4. Click OK.

22.4.3 How to Define a Correlation Using Advanced Mode

Advanced mode enables you to define multiple correlation keys with multiple correlation properties.

To define a correlation using advanced mode:

  1. In the Correlation Definition dialog box, click Switch to Advanced Mode.

    The Correlation Keys table appears.

  2. For each of the correlation keys you want to add to the correlation:

    1. Click the Add button.

      The Create CorrelationKey dialog box appears.

    2. Select an existing correlation key or click the New Correlation Key button to create a new correlation key.

      For more information on how to define a new correlation key, see How to Configure a Correlation Key.

    3. If the BPMN element initiates the value of the correlation, select Initiates.

    4. Click OK.

  3. In the Correlation Property Aliases section, for each of the listed properties, define an expression to assign a value to the correlation property.

    To define a complex expression, click the Expression Builder button next to the property text box. For more information see Writing Expressions.

  4. Click OK.

    The Correlation Definition dialog box closes and the Correlations icon appear in colors now.

22.5 Creating Correlations Keys

Since you define correlation keys at project level you can reuse correlation keys across the processes in your project. You can also decide to create correlation keys before adding the flow objects that use them. For both of these cases you must create correlation keys from the Structure view.

Note:

Updates to a correlation key made using the runtime interface do not change the existing subscription, even though the GUI may reflect the change. The change is applicable to subsequent events in the flow.

22.5.1 How to Create a Correlation Key

You can create a correlation key at a project level and later use that correlation key to define the correlations of your flow objects.

To create a correlation key:

  1. Select a business process.
  2. Open the Structure view.
  3. Expand the Correlations node in the Structure view.
  4. Right-click the Correlations Keys node.
  5. Select New.

    The Create Correlation Key dialog box appears.

22.5.2 How to Configure a Correlation Key

You can configure the properties that compose the correlation keys you define.

To configure a correlation key:

  1. Enter the correlation name.

  2. If the Correlation Properties list is empty or the property that you want to use for your correlation is not defined, you must define a new correlation property. To define a correlation property:

    1. Click the New button.

      The Create Correlation Property dialog box appears.

    2. Enter a name for the correlation property.

    3. Select a type.

      Available types are: string, int, double, decimal, boolean, time.

    4. Click OK.

  3. Select the correlation properties that define the correlation:

    1. From the Correlation Properties list, select the property you want to include in the correlation.

    2. Click the Select button.

      The selected property appear in the Selected list.

  4. Click OK.