SOA 11g Correlation

Embed Size (px)

Citation preview

  • 8/10/2019 SOA 11g Correlation

    1/4

    Correlations between Requests and Response from services:

    Oracle SOA 11g :Oracle BPEL provides us with two mechanisms through which an asynchronous callbackmessage could map to its calling instance in the crowd.1. WS-Addressing2. Correlation Sets

    WS-Addressing How does the callback maps to the correct instance out of so many waitingprocesses, its a very common surprise to all beginners, creating first ever Asynchronous Invokein BPEL Process Manager. The answer is, any time an asynchronous service is invoked, OracleBPM, instills a message UID in WS-Addressing headers that float with SOAP Packets, which areused internally by the BPEL Server to correlate the flowing request/response.

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

    Correlation SetsCorrelation Sets enable you to correlate asynchronous messages based onmessage body contents.

    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 wont have to; if the calledservice 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 thatcome to my mind are

    1. The asynchronous web service invoked by BPEL does not support/understand WS-Addressingheaders.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. Forexample, 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 achievecorrelation. In WS-Addressing, we, as in developer, does not bother of how the correlation ID iscreated and maintained. However, in content-based correlation the responsibility of managingcorrelation set, defining property alias and initializing the correlation with appropriate value fallson developer.

    To understand how to perform these tasks, we would start by understanding in which activities dowe need correlation. The Correlation is required whenever data is going out or coming in to theBPEL 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 isa set of properties shared by all messages in the correlated group.

  • 8/10/2019 SOA 11g Correlation

    2/4

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

    However, when you have to create correlation set on invoke, we have one addition option tounderstand, its the pattern. Now before we move ahead with pattern, lets explore what isinitiate option.

    If initiate option is set to yes this means that we assign the value to correlation variable. Wheninitiate option is set to no this means, we want to validate the value against, value stored incorrelation variable.

    With this in mind, we would try to understand, the pattern option of Correlation tab in invokeactivity.

    When initiate = yes,Pattern=in means the correlation isbeing 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 asynchronousprocess, as the pattern suggests a response coming back.Pattern = out means the correlation is being instantiated on the message that is going out of ourBPEL.Pattern = out-in means the correlation would be set on a variable that is part of both outgoingand incoming parameter, in this synchronous invoke. However, its nature is very muchquestionable.

    When initiate=noThe above patterns would reflect which way the variable needs to be validated, inward, outward orboth ways.

    Creating a Correlation Set

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

    http://4.bp.blogspot.com/_InZVG6F1ZIc/R58Mzy5_s-I/AAAAAAAAAAs/N53X6K1asHU/s1600-h/invokePattern.jpghttp://4.bp.blogspot.com/_InZVG6F1ZIc/R58Mzy5_s-I/AAAAAAAAAAs/N53X6K1asHU/s1600-h/invokePattern.jpghttp://4.bp.blogspot.com/_InZVG6F1ZIc/R58Mzy5_s-I/AAAAAAAAAAs/N53X6K1asHU/s1600-h/invokePattern.jpghttp://4.bp.blogspot.com/_InZVG6F1ZIc/R58Mzy5_s-I/AAAAAAAAAAs/N53X6K1asHU/s1600-h/invokePattern.jpghttp://4.bp.blogspot.com/_InZVG6F1ZIc/R58Mzy5_s-I/AAAAAAAAAAs/N53X6K1asHU/s1600-h/invokePattern.jpghttp://4.bp.blogspot.com/_InZVG6F1ZIc/R58Mzy5_s-I/AAAAAAAAAAs/N53X6K1asHU/s1600-h/invokePattern.jpghttp://4.bp.blogspot.com/_InZVG6F1ZIc/R58Mzy5_s-I/AAAAAAAAAAs/N53X6K1asHU/s1600-h/invokePattern.jpg
  • 8/10/2019 SOA 11g Correlation

    3/4

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

    Here you would also need to create a Property (not shown in diagram above, its just beneathXpath text box. This way we declared one of the property alias for instantiation, we need to createanother 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. Youcan use Ctrl+Space for Autofill.

    http://1.bp.blogspot.com/_InZVG6F1ZIc/R58N6C5_tBI/AAAAAAAAABE/vzkAtiemgRg/s1600-h/CreatePropAlias.jpghttp://3.bp.blogspot.com/_InZVG6F1ZIc/R58N5i5_tAI/AAAAAAAAAA8/UqGVoHBpdx4/s1600-h/CrCorrSet.jpghttp://1.bp.blogspot.com/_InZVG6F1ZIc/R58NTC5_s_I/AAAAAAAAAA0/wnoPcK457xw/s1600-h/createIcon.jpghttp://1.bp.blogspot.com/_InZVG6F1ZIc/R58N6C5_tBI/AAAAAAAAABE/vzkAtiemgRg/s1600-h/CreatePropAlias.jpghttp://3.bp.blogspot.com/_InZVG6F1ZIc/R58N5i5_tAI/AAAAAAAAAA8/UqGVoHBpdx4/s1600-h/CrCorrSet.jpghttp://1.bp.blogspot.com/_InZVG6F1ZIc/R58NTC5_s_I/AAAAAAAAAA0/wnoPcK457xw/s1600-h/createIcon.jpghttp://1.bp.blogspot.com/_InZVG6F1ZIc/R58N6C5_tBI/AAAAAAAAABE/vzkAtiemgRg/s1600-h/CreatePropAlias.jpghttp://3.bp.blogspot.com/_InZVG6F1ZIc/R58N5i5_tAI/AAAAAAAAAA8/UqGVoHBpdx4/s1600-h/CrCorrSet.jpghttp://1.bp.blogspot.com/_InZVG6F1ZIc/R58NTC5_s_I/AAAAAAAAAA0/wnoPcK457xw/s1600-h/createIcon.jpg
  • 8/10/2019 SOA 11g Correlation

    4/4

    Now, select the appropriate message part, and then enter Xpath query string in the text box. Youcan use Ctrl+Space for Autofill.In common business scenarios it is not possible to have a synchronousresponse to each of our requests. Mostly the business has to deal with vendors, who would need toundergo a detailed process to come up with a solution. However, this response may not be necessarilybinding business from carrying on its other activities. In such scenarios, the business enters in toasynchronous communication with these third parties. The async process necessarily stresses that theresponse 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 aremultiple 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 theairline to return this id unaltered to match the request. This id, which enables requestor to correlate theresponse sent by the provider, is called Correlation Id.

    http://1.bp.blogspot.com/_InZVG6F1ZIc/R58N6C5_tCI/AAAAAAAAABM/yTT2nKtmz8k/s1600-h/CreatePropAlias2.jpg