Sunday, October 4, 2009

Oracle BPEL Correlation Exemplified

Correlation is one of the important & tricky technique available within Oracle BPEL PM. In this blog, I have taken a simple route to explain the correlation technique.

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.
For reference on WS-Addressing click here

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.


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 pro1 -> pro2 -> pro3 and response is received from pro3 ->pro1

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

Initiate Attribute: (Value Set - yes, no)
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

Pattern Attribute: (Value Set - in, out, in-out)
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. thank you very much... this is very useful

  2. Very good post.
    So WS-Addressing is replacement of Correlation mechanism if I want to track requests and responses in async bpel? I mean can I use either one to achieve this?

  3. For a normal BPEL asynchronous callback you don't have to implement any special thing. However if the callback is supposed to happen from a different process altogether where you have a unique identifier in your message, you can implement content based correlation feature on sending and receiving nodes.

  4. Thanks for your reply Sathya.
    So I have soa application with human task and which will be invoked from some web application X(creates tasks). User will log in using a separate ADF application and do actions on assigned tasks. So in this case
    If I want to use ws-addressing for message tracking, What should I do from web application X side while invoking my soa app. Do I need to add some ws-addreessing stuff in soap header? Please provide your inputs.

  5. Hi Sathyam,

    Can you explain what is pick activity and how it is used in BPEL.
    Kindly explain with example


    1. Hi Mithun, Of late I have been getting similar requests. I am planning to blog a series of posts for basic BPEL/SOA concepts which will cover your need.

      Appreciate your interest. Subscribe to my posts and you will be notified :)

  6. Hi Sathya,
    Can you please help me how to use receive and pick activity in single BPEL


    1. Hi Mithun, I think it has been a long time. I have been travelling a lot and couldn't find time to write as much as I would have liked to. But here you go.. I have posted a pick receive example with use-case and sample code here:

      Appreciate your interest and looking forward for any requests that you might have. I will try my best to accomodate them in my blog.

  7. Hi Satya,

    can you tell how to use correlation set with a bpel process having a pick construct?( pick construct has two onMessage blocks)


    1. Hi Bindu,

      Correlation behaves pretty much the same way. Once you set the correlation set to initiate on the "Invoke" where you call the service, set the same correlation set on each of your "onMessage" branches.

  8. Hi Sathya,
    Can you please explain pick activity with both onmessage & onalarm activity with suitable example


  9. Mithun,
    I think you haven't read my earlier response. Pick activity with example is available at my blog post here :

  10. could you please provide a sample source code which shows correlation demo?

  11. Hi sathya,
    the error i am facing is when i use 2 receives in a bpel, the first one to get a string input and the second to get a file from file adapter with read operation, the flow trace shows waiting for asynchronous callback
    no progress from der.

    1. You must use the syncread option for your second receive.

  12. Could you please explain d/b asynchronous process and correlation set

  13. Hi Sathya,

    I've want use this correlation property to send a reference varible /value in the request message that i can use as a parameter in if condition for condiotional mapping instead of using any of the actual request variable.

    Can you help me with that.


    1. Hi Abhijeet,

      I don't think I understand your usecase. Correlation is contextual data from a process instance to uniquely identify it again from a different thread. Can you explain your usecase?