Thursday, May 28, 2015

Correlation in Oracle BPEL

Correlation is one of the important & tricky technique available within Oracle BPEL PM.

Synchronous & Asynchronous web services:

Whenever a synchronous web service is invoked from Oracle BPEL via a partnerlink, only one port is established for communication with the exposed web service which is used by both request & response messages. However, when an asynchronous web service is invoked, two ports are opened for communcation: one for request & one for response messages.

How does Oracle BPEL identify asynchronous responses?

As response from an asynchronous web service is not guaranteed to be received within a specified time frame, and many instances of the same service might be invoked before even a response can be obtained, how does Oracle BPEL identify and relate the responses to the appropriate requests and proceed for completion of further activities that may be scheduled? The answer is "WS-Addressing".

What is WS-Addressing?

WS-Addressing is a transport-neutral mechanism by which web services communicate addressing information. SOAP envelopes & headers used within web services for transporting data throught transport layers like HTTP does not possess intelligence to specify unique addressing information. Hence, WS-Addressing evolved which contained endpoint references (EPR) and message information headers for identification. This information is processed independently of the transport mechanism or application.

By default, Oracle BPEL PM implements WS-Addressing for all asynchronous web service calls, hence we don't have to explicitly implement identification relationship between the incoming & outgoing messages.

Correlation:

In short, Correlation is a BPEL technique which provides correlation of asynchronous messages based on the content of the message.

Why & Where Correlation?

The following are few scenarios in which we would be required to implement Correlation to identify & relate message communication;

  1. When the external web service called doesn't have WS-Addressing capability
  2. When the message travels through several services and response is solicited by the initial service from the last service directly
For instance, request flow process1 -> process2 -> process3 and response is received from process3 ->process1

Implementing Correlation:

a) Creating Correlation Sets:

In Structure Window of the JDeveloper IDE, right click on the Correlation Sets and choose 'Create Correlation Set' Provide a name for your correlation set being created.
In the properties section, select 'Add' to display the property chooser window Choose 'Create' to create a property on which the correlation has to be initiated. Provide a name and type for the property.

b) Associating the Correlation set on receive/invoke, pick activities

Go the the correlations tab on the activity (invoke/receive/pick) on which you need to set & validate the correlation Add the created correlation set to the activity


When set to yes, correlation set is initiated with the values of the properties available in the message being transferred When set to no, correlation set validates the value of the property available in the message


When the value is 'in', it means that the correlation property is set/validated on the incoming message When the value is 'out', it means that the correlation property is set/validated on the message going out of BPEL In case of 'in-out', the property will be set/validated on both incoming & outgoing messages

c) Creating Propery Alias:

In the Structure Window of the JDeveloper, right click on the 'Property Aliases' and select 'Create Propery Alias' Select the message type that you want to set to the correlation propery (already created)

Now, correlation design is complete. However, correlation will not be established unless we reference the correlations on the WSDL file of the BPEL process. To do this, import the correlation WSDL file (created under the project) in the BPEL process main WSDL.


1 comment: