Correlation is one interesting area which I always wanted to write on. Recently we got to work extensively on implementing correlations. I will list down some of the issues we had while implementing the correlation for complex workflows.
Why we need correlation?
Interaction patterns can be mainly grouped into Synchronous and Asynchronous. In case of Synchronous the request and reply happens using the same port and the pipe is open till the reply is back. But in case for Asynchronous there are separate ports for both request and reply and because of this the message needs to be tracked so that reply goes to the same request. The correlation mechanism helps to track and route messages to appropriate process instances.
So in case of normal BPEL asynchronous calls BPEL Engine takes care of correlating the message to the instance by assigning a unique correlation id. In case of scenarios where process AàBàCàA or A->B->C->D->A (-> = calls) the correlation has to be taken care by the developer by using correlation sets.
Issues /workarounds while using correlations
Scenario: The example scenario I will be taking will be Agile-
Here correlation sets are created and assigned while invoking the partner services.
In this flow the out of the box PIP supports only processing of Parts which are of type Item. One of the Clients had a requirement to process Parts which are of type documents. For this we added one more ProvABCS and we had 2 parallel flows which will look like below.
1. -> BPEL1(
2. -> BPEL1(
So for correlating this new flow we created one more correlation set in the same scope and tested the flow.
Issue #1
The response message was not able to properly identify the unique correlation set and was failing.
Staktrace snippet
"ORABPEL-03813 Failed to evaluate correlation query. Failed to evaluate the correlationAlias query "/geo:ResponseMessage/header:Header/header:RequestEBMID" on the element "oracle.xml.parser.v2.XMLElement@1473827" Please check your BPEL/WSDL source to make sure that property alias is defined correctly. at com.collaxa.cube.engine.delivery.CorrelationProperty.setMessagePart(CorrelationProperty.java:85) at com.collaxa.cube.engine.delivery.DeliveryHelper.createCorrelationSet(DeliveryHelper.java:148)
Workaround
- Create separate scopes for both the flows.
- Create Correlation sets for each of the flow in their specific scopes.
Test it and it should work properly.
Life is never easy. The new requirement was to call the new Prov ABCS process as many times as there are documents in the payload and at a time there will be multiple items and documents. So while implementing this we ran into our second issue.
Issue#2
While invoking the ProvABCS process in a loop BPEL engine threw the error.
“cannot initiate correlation set more than once”. It meant we cannot initiate the same instance of correlation set again and again.
Stack Trace snippet
Correlation Violation - cannot initiate correlation set more than once
Workaround
The issue is with initiate attribute where we have mentioned it “initiate=yes”. When we look at the BPEL specifications there are 3 values possible for the
Initiate attribute of correlation set. They are
· yes. to initiate the correlation set.
· no. This is the default option. Activity should not initiate the correlation set.
· join. If the correlation set is not yet initiated, initialize it.
Join attribute was the apt choice here, but the attribute join is not supported by Oracle BPEL PM. This is because the implementation of initiate attribute is declared as a Boolean value, it supports only yes/no.
So next option was to create a separate inner scope inside the while loop and declare the correlation specific inside the inner scope. By doing that, our intention is to isolate the initialized value and will get nullified once we come out of the inner scope. So in each loop, a new instance of correlation set will get initialized when flow enters the inner scope and dies when the scope gets over. This will eliminate the issue due to initiation of the same correlation set more than once.
Special thanks to Haresh who worked on trying out different options to make correlations work and helping me this blog.
That’s it on correlation, now back to football J