Tuesday, January 29, 2008

Correlation Illustrated

Correlation

This post would effort to explore the meaning and need of correlating requests and the best way to do them using Oracle SOA Suite.

What & Why
In common business scenarios it is not possible to have a synchronous response to each of our requests. Mostly the business has to deal with vendors, who would need to undergo a detailed process to come up with a solution. However, this response may not be necessarily binding business from carrying on its other activities. In such scenarios, the business enters in to asynchronous communication with these third parties. The async process necessarily stresses that the response may come back at a later time, through callback or polling mechanism as is suitable.

In case of a single instance its quite easy to match the response to request, however, when there are multiple instances the business would be wondering which request has been responded to. For example, if a travel booking agent spawns 10 requests for Frankfurt to Paris, and after a while airline responds to one of those 10 requests, it would not be safe to assume that this is a response to first request only. Hence the travel agent would tag in an ID to segregate one request for another, and would expect the airline to return this id unaltered to match the request. This id, which enables requestor to correlate the response sent by the provider, is called Correlation Id.

How (in Oracle BPEL)
Oracle BPEL provides us with two mechanisms through which an asynchronous callback message could map to its calling instance in the crowd.

  • WS-Addressing
  • Correlation Sets

WS-Addressing
“How does the callback maps to the correct instance out of so many waiting processes”, it’s a very common surprise to all beginners, creating first ever Asynchronous Invoke in BPEL Process Manager. The answer is, any time an asynchronous service is invoked, Oracle BPM, instills a message UID in WS-Addressing headers that float with SOAP Packets, which are used internally by the BPEL Server to correlate the flowing request/response.

This is the default mechanism supported by Oracle BPEL Process Manager, which is overridden automatically when the user opts to create his own correlation set.

Correlation Sets
Correlation Sets enable you to correlate asynchronous messages based on message body contents.

Why?

The question now arises, why ever would a BPEL developer like to over-ride default WS-Addressing correlation and use content-based correlation. Well, he won’t have to; if the called service is an Oracle BPEL, or the one, which supports and retains WS-Addressing headers sent, and returns the same in response.

The reasons, to use content-based correlation, could be many; some of the familiar ones that come to my mind are –

1. The asynchronous web service invoked by BPEL does not support/understand WS-Addressing headers.
2. When BPEL instance is expecting messages from a third party, for example, a file-poller.
3. When asynchronous call has multiple hops and reply is received directly from end system. For example, Request path is A > B > C > D and response comes to A directly from D, i.e. D > A.

How?

WE now understand and appreciate, need of correlation and the two mechanisms to achieve correlation. In WS-Addressing, we, as in developer, does not bother of how the correlation ID is created and maintained. However, in content-based correlation the responsibility of managing correlation set, defining property alias and initializing the correlation with appropriate value falls on developer.

To understand how to perform these tasks, we would start by understanding in which activities do we need correlation. The Correlation is required whenever data is going out or coming in to the BPEL process, hence Correlation works only with Invoke, Receive, Pick and Reply activities.

To create a correlation of our own, we need to create the Correlation Set first. A correlation set is a set of properties shared by all messages in the correlated group.

The correlation set is normally instantiated on invoke or receive activity. When correlation is instantiated on receive activity it is fairly straight forward, you create a correlation set, and select initiate = “yes”.

However, when you have to create correlation set on invoke, we have one addition option to understand, it’s the “pattern”. Now before we move ahead with “pattern”, lets explore what is “initiate” option.





If initiate option is set to “yes” this means that we assign the value to correlation variable. When initiate option is set to “no” this means, we want to validate the value against, value stored in correlation variable.

With this in mind, we would try to understand, the “pattern” option of Correlation tab in invoke activity.

When initiate = “yes”,
Pattern=”in” means the correlation is being instantiated with a value that is coming into the BPEL, from another service. Clearly, this invoke is then not the one which is invoking an asynchronous process, as the pattern suggests a response coming back.
Pattern = “out” means the correlation is being instantiated on the message that is going out of our BPEL.
Pattern = “out-in” means the correlation would be set on a variable that is part of both outgoing and incoming parameter, in this synchronous invoke. However, its nature is very much questionable.

When initiate=”no”
The above patterns would reflect which way the variable needs to be validated, inward, outward or both ways.

Creating a Correlation Set 

Correlation sets uses correlation tokens available inside messages, headers or business documents. Correlation tokens are the declarative properties of messages. A property is an element within a message identified by a query. Property aliases are the constructs to specify the queries to identify properties.

To create Correlation Set click the Create icon, and insert the appropriate values. As shown in the diagram below:



Here you would also need to create a Property (not shown in diagram above, its just beneath Xpath text box. This way we declared one of the property alias for instantiation, we need to create another one for validation.

Select the BPEL in diagram, in the adjacent Structure window, you would see set of properties. Right Click Property Alias, and select “Create Property Alias…”.



Now, select the appropriate message part, and then enter Xpath query string in the text box. You can use Ctrl+Space for Autofill.




Now, select the appropriate message part, and then enter Xpath query string in the text box. You can use Ctrl+Space for Autofill.

References :
Antony Reynold's Correlation
Antony Reynold's on Pattern and Initiate

12 comments:

Unknown said...

Wow, that very neat explaination. Thanks dude

Madhu said...

Hi,

I have a bpel process wherein I have muliple receive activities for a single port not parallel. Ther are all subsequent. How can i use correlation in such a process?

Thanks

Publishing Editor said...

Another resource you might want to look at is http://bpelresource.com/

Tonmoy said...

Very nicely explained. Thanks a lot. Keep writing such useful posts. :)

pankaj said...

Very Gud post....simple and clear even begainer can understnad it easily....:)

Tani said...

That very neat explanation on the need of correlating requests and the best way to do them using Oracle SOA Suite. thanks for sharing.


sap upgrade challenges

Rajashekar Reddy said...

Nice way of explanation, keep going.

21st Century Software Solutions said...

bpel developer online training| bpel developer training| call ...
http://www.21cssindia.com/courses/bpel-developer-online-training-66.html
BPEL Developer Online Training, BPEL Developer training, BPEL Developer course contents, BPEL Developer Employees to learn at their own pace and maintain control of learning “where, when and how” with boundless access 24/7by 21st Century Software Solutions. contact@21cssindia.com ---- Call Us +917386622889

Unknown said...

Great Information admin thanks For Your Blog and Any body wants learn Business Analyst through Online for Details Please go

through the Link

QA Oracle SOA Online Training with real time projects Worldwide

This Will Helps you alot.

Unknown said...

Oracle SOA is known as the Industry’s Most Complete and Unified Application Integration and SOA Solution. It transforms complex application integration into agile and re-usable service-based connectivity to speed time to market, respond faster to business requirements, and lower costs. Smartminds provides Oracle DBA Online Training Class course by excellent experienced IT professionals who has real time experience
oracle soa online training
program classes by Smartmind with highly-qualified and excellent seasoned trainers, We've started this Oracle SOA courses with much love of giving fantastic best-value understanding of Oracle SOA individuals we additionally supplying extensive group of material for our individuals which means you may move through that information and will recognize within an effective strategy.

21st Century Software Solutions said...

BPEL Developer Online Training, ONLINE TRAINING – IT SUPPORT – CORPORATE TRAINING http://www.21cssindia.com/courses/bpel-developer-online-training-66.html The 21st Century Software Solutions of India offers one of the Largest conglomerations of Software Training, IT Support, Corporate Training institute in India - +919000444287 - +917386622889 - Visakhapatnam,Hyderabad BPEL Developer Online Training, BPEL Developer Training, BPEL Developer, BPEL Developer Online Training| BPEL Developer Training| BPEL Developer| "Courses at 21st Century Software Solutions
Talend Online Training -Hyperion Online Training - IBM Unica Online Training - Siteminder Online Training - SharePoint Online Training - Informatica Online Training - SalesForce Online Training - Many more… | Call Us +917386622889 - +919000444287 - contact@21cssindia.com
Visit: http://www.21cssindia.com/courses.html"

U Learn Systems said...

Hi friend iam providing the safe agile certification of various online trainings like PMP,PRINCE2,ACP,PSM,CSM.