How does BPEL identify which response is for which request?
We all know that there are two major type of processing
synchronous and asynchronous and for synchronous processing it uses same TCP
connection or in simpler terms single port. So there is no need of correlation
for synchronous process.
For Asynchronous processing, BPEL process will usually
correlate message using "WS-Addressing", it’s something like web session cookies,
which happens internally and we do not need to worry about correlating response
messages.
WS-Addressing
The basic question every beginner has is how an asynchronous
response gets mapped to the correct instance out of many waiting instances. The
answer is, whenever asynchronous service is invoked, Oracle BPM adds a
message UID in WS-Addressing headers that flows with SOAP packets, which are
used internally by BPEL server to correlate the request/response.
So when does we need manual Correlation?
Below are the scenarios when we will require correlation:
What is correlation?
- When external web service doesn’t support WS-Addressing
- When the message travels through several services and the response is solicited by the initial service from the last service directly. For example, Request path is A > B > C and response comes to A directly from C, i.e. C > A
- When receiving unsolicited messages from another system.
- When communicating via files, i.e. When BPEL instance is expecting messages from a third party.
What is correlation?
It is a BPEL technique called correlation set to match or
correlate the messages based on content of the message.
It is a collection of properties used by the BPEL process
service engine to allow custom correlation.
Before starting with our example we need to understand in
which activities do we need correlation. Well the answer is quite self-explanatory,
we need correlation whenever data is going out or coming in to the BPEL process,
i.e.
- Receive activity
- Reply activity
- Invoke activity
- onMessage branch
- onEvent branch
I will first give the scenario of our example:
you can download the sample from here.
we will have two receive activities in our BPEL process,
One receive will take input as Country Name and Language
Other receive will take input as Country Name and Capital.
The response will have Country Name, Language and Capital.