IBM Support

Correlation sets in BPEL processes

Troubleshooting


Problem

A correlation set allows a BPEL process instance to hold conversations with partners involved in its work. This technote describes the use of a correlation set in process instance initiating activities and non-initiating receive activities.

Resolving The Problem

During the lifetime of a process instance, it typically holds one or more conversations with partners involved in its work. BPEL addresses correlation scenarios by providing a mechanism to specify one or more correlation sets. Correlation sets are instantiated within the scope of a process instance and uniquely identify the process instance.

You can use correlation sets in invoke, receive, pick, and reply activities to indicate which correlation sets occur in the messages that are sent and received. The values of each correlation set uniquely identify the process instance. This is true even if the process instance has already reached an end state, such as the finished state.

A correlation set is required if a process consists of more than one receive or pick activity. The receive or pick activity that initiates a new process instance does not necessarily need a correlation set. The remaining receive or pick activities, however, need a correlation set because the value of the correlation set which is passed with the message is used to uniquely identify the process instance the message is then routed to.

In the following, the effects of using correlation sets in process-instance-initiating and non-initiating receive activities are described over the lifetime of a BPEL process. For this purpose, a process containing two receive activities that can initiate process instances and a receive activity that cannot initiate process instances are used. Only the relevant WSDL and BPEL snippets are shown here. The snippets are taken from the Order Processing sample that is shipped with WebSphere Business Integration Server Foundation V5.1 and adapted slightly for this example.

WSDL snippet
The WSDL snippet defines a property named orderNo and maps it via property aliases to concrete message parts in the message types productData, personalData, and shipmentAck.

<bpws:property name="orderNo" type="xsd:string"/>
<bpws:propertyAlias messageType="tns:productData"
      part="orderNo" propertyName="tns:orderNo" query=""/>
<bpws:propertyAlias messageType="tns:personalData"
      part="orderNo" propertyName="tns:orderNo" query=""/>
<bpws:propertyAlias messageType="tns:shipmentAck"
      part="orderNo" propertyName="tns:orderNo" query=""/>

BPEL snippet
The BPEL snippet defines:

  • A correlation set named TheOneAndOnlyCorrelationSet
  • The variables productData, personalData, and shipmentAck
  • The receive activities GetLoginData and GetProductData. These activities can both create a process instance and initiate the correlation set.
  • The receive activity GetShipmentAck. This activity uses the correlation set but it cannot initiate a new process instance.

Process definition
For convenience, the two receive activities that can create process instances, GetLoginData and GetProductData, are inside a flow activity. This flow activity and the remaining receive activity, GetShipmentAck, are inside a sequence activity.

<process name="orderProcess" ...>

  <correlationSets>
    <correlationSet name="TheOneAndOnlyCorrelationSet"
                    properties="wsdl0:orderNo"/>
  </correlationSets>

  <variables>
    <variable messageType="wsdl0:productData"
              name="productData"/>
    <variable messageType="wsdl0:personalData"
              name="personalData"/>
    <variable messageType="wsdl0:shipmentAck"
              name="shipmentAck"/>
  </variables>

  <sequence>
    <flow>
      <receive createInstance="yes" name="GetLoginData"
        operation="enterLoginData" partnerLink="InternetCustomer"
        portType="wsdl0:customerPort" variable="personalData"
        wpc:displayName="getLoginData" wpc:id="2">
        <correlations>
          <correlation initiate="join"
                       set="TheOneAndOnlyCorrelationSet"/>
        </correlations>
      </receive>

      <receive createInstance="yes" name="GetProductData"
        operation="enterProductData" partnerLink="InternetCustomer"
        portType="wsdl0:customerPort" variable="productData"
        wpc:displayName="getProductData" wpc:id="3">
        <correlations>
          <correlation initiate="join"
                       set="TheOneAndOnlyCorrelationSet"/>
        </correlations>
      </receive>
    </flow>

    <receive createInstance="no" name="GetShipmentAck"
      operation="receiveShipmentAck" partnerLink="ShipmentService"
      portType="wsdl0:shipmentDataPort" variable="shipmentAck"
      wpc:displayName="getShipmentAck" wpc:id="13">
      <correlations>
        <correlation initiate="no"
                     set="TheOneAndOnlyCorrelationSet"/>
      </correlations>
    </receive>
  </sequence>

</process>


Initiation of a new proces instance
It is assumed that a message of type personalData with orderNo part set to Order1 has already been sent to the customerPort port type and the enterLoginData operation. This message creates an instance of the orderProcess process and triggers the navigation of the corresponding GetLoginData receive activity.

This means that the GetLoginData activity is in the finished state, the GetProductData activity is in the waiting state, and the GetShipmentAck activity is still in the inactive state.


The GetLoginData receive activity accepts a request
Now, let's see what happens if one of the messages below is sent:
  • Another message of type personalData with part orderNo set to Order1 is sent to port type customerPort and operation enterLoginData.

    Because an instance of the orderProcess process with the same value of the correlation set exists, this message is routed to the existing process instance. However, with regard to this process instance the GetLoginData receive activity that corresponds to the customerPort port type and the enterLoginData operation has already been navigated and therefore this message cannot be consumed by the process instance and it is rejected with the message: BPEE0037E: Event unknown.
  • Another message of type personalData with part orderNo set to Order2 is sent to port type customerPort and operation enterLoginData.

    Because there is no instance of the orderProcess process with the same value of the correlation set, this message creates an orderProcess process instance and triggers the navigation of the corresponding GetLoginData receive activity.
  • A message of type productData with part orderNo set to Order1 is sent to the customerPort port type and the enterProductData operation.

    Because an instance of the orderProcess process with the same value of the correlation set exists, this message is routed to the existing process instance and triggers the navigation of the GetProductData receive activity that corresponds to the customerPort port type and the enterProductData operation.
  • A message of type productData with part orderNo set to Order3 is sent the customerPort port type and the enterProductData operation.

    Because there is no instance of the orderProcess process with the same value of the correlation set, this message creates an orderProcess process instance and triggers the navigation of the corresponding GetProductData receive activity.
  • A message of type shipmentAck with part orderNo set to Order1 is sent to the shipmentDataPort port type and the receiveShipmentAck operation.

    Because an instance of the orderProcess process with the same value of the correlation set exists, this message is routed to the existing process instance. However, because the navigation of the process instance has not yet reached the GetShipmentAck receive activity that corresponds to the shipmentDataPort port type and the receiveShipmentAck operation, the message does not immediately trigger the navigation of this receive activity but is noticed with the process instance for later consumption. This behavior is described as "post before wait".
  • A message of type shipmentAck with part orderNo set to Order4 is sent to the shipmentDataPort port type and the receiveShipmentAck operation.

    Because there is no instance of the orderProcess process with the same value of the correlation and the GetShipmentAck receive activity cannot create a new process instance, this message cannot be consumed by the process choreographer engine and it is rejected with the message: ILMC0006W: Instance not found, and create instance was false for this operation.


The GetLoginData and GetProductData receive activities accept a request
For the continuing observations, it is assumed that a message of type productData with part orderNo set to Order1 is sent to the customerPort port type and the operation enterProductData. This message is routed to the existing process instance and triggers the navigation of the corresponding GetProductData receive activity. This means that the GetLoginData and the GetProductData activities are now in the finished state, and the GetShipmentAck activity is in the waiting state. Now, let's see what happens if one of the messages below is sent:
  • A message of type productData with part orderNo set to Order1 is sent to the customerPort port type and the enterProductData operation.

    Because an instance of the orderProcess process with the same value of the correlation set exists, this message is routed to the existing process instance. However, with regard to this process instance, the GetProductData receive activity has already been navigated and therefore this message cannot be consumed by the process instance and it is rejected with the message: BPEE0037E: Event unknown.
  • A message of type shipmentAck with part orderNo set to Order1 is sent to the shipmentDataPort port type and the receiveShipmentAck operation.

    Because an instance of the orderProcess process with the same value of the correlation set exists, this message is routed to the existing process instance and triggers the navigation of the GetShipmentAck receive activity that corresponds to the shipmentDataPort port type and the receiveShipmentAck operation.
  • The other messages show the same behavior as outlined above.


The GetLoginData, GetProductData and GetShipmentAck receive activities accept a request
Finally, it is assumed that a message of type shipmentAck with part orderNo set to Order1 is sent to the shipmentDataPort port type and the receiveShipmentAck operation. This message triggers the navigation of the corresponding GetShipmentAck receive activity and the process instance runs to completion. This means that all the activities are in the finished state. Now, let's see what happens if one of the messages below is sent:
  • A message of type shipmentAck with part orderNo set to Order1 is sent to the shipmentDataPort port type and the receiveShipmentAck operation.

    Because an instance of the orderProcess process with the same value of the correlation set exists, this message is routed to the existing process instance. However, with regard to this process instance, the GetShipmentAck receive activity that corresponds to the shipmentDataPort port type and the receiveShipmentAck operation has already been navigated. Therefore, this message cannot be consumed by the process instance and it is rejected with the message: BPEE0037E: Event unknown.
  • The other messages show the same behavior as outlined above.

After the process instance completes
To create a process instance of the orderProcess process with a correlation value of Order1, you must delete the existing process, for example, using the process choreographer Web client.


How to create a correlation set using WID
To see some examples of how to create a correlation set in a business process that you can build and run yourself, go to http://publib.boulder.ibm.com/bpcsamp/index.html, click Advanced BPEL features, and choose from either of the following samples:
  • Correlation
  • Multiple Correlation Sets


Common mistakes when creating a correlation set
The properties of a correlation key do not constitute a unique key to distinguish a process instance from another within a runtime environment. That is, when selecting the properties of a correlation key keep in mind that these properties together allow to uniquely identify a process instance
  • independently of its state (particularly even in state finished)
  • across all versions of a process model.

The Initiation field of a correlation set is not set correctly. The initiation field is used to configure how the correlation set will be initialized. When multiple activities can initialize the correlation set, the value Join must be selected.

[{"Product":{"code":"SSQH9M","label":"WebSphere Process Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Business Flow Manager","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;6.2;6.1","Edition":"Enterprise","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21171649