In this example, we will go through a simple example to understand the correlation set.
Suppose, an asynchronous BPEL process is initiated to raise an order item and you want to cancel the same order. Then how does BPEL process will know which order should be cancelled. Correlation set and WS-addressing will be used to identify the correct BPEL process instance. Synchronous BPEL process does not require this type of addressing. In asynchronous BPEL process, correlation set enables you to correlate the incoming messages based on property set and property alias.
When we need to interact with asynchronous BPEL service that does not support WS-addressing and when the message travels through different system which is solicited from last service directly, then we require implementing correlation set. Correlation set is used in receive, reply, invoke, on message, on event activity.
- Create a new SOA application and SOA project with an asynchronous BPEL process. Edit XSD and WSDL of BPEL process
- Now the modified WSDL will look like this
- Select Wait activity from BPEL component and drag and drop it between receiveInput and callbackClient. Set 1 hr time for wait activity.
- Add OnEvent in the BPEL process
- Double click on Onevent and editor of OnEvent will open. Select processcancellation operation of Correlation BPEL process and create one variable of CorrelationBPELProcessCancelMessage type
- Add an Exit activity in the OnEvent block, so that after cancellation process will be aborted.
- Create a correlation set in receive activity. Go to Correlations tab and click on green plus sign and browse the correlation set. Again click on green plus sign like below screenshot
- Then create property and property alias. Click on green plus sign in Create Correlation Set window and property type will be integer.
- Create property alias also that will be the request message of BPEL process. Click on OK button.
- Now select the newly created correlation set and initialize it.
- Correlation set is created for receive activity. We have to select same correlation set with new property alias in event activity also. Set initiate asA�NO.
- Save the project and deploy it in server. Test the application in EM console. Create an order by selecting operation as process and check the flow status. This flow instance will be in running status.
- Again test this application with operation process cancellation and check the flow instance. This time flow instance will be completed, but the previous process will be still in running status.
- Then test the process cancellation operation with the first order id. First flow instance will be aborted as we have selected exit activity in event block which will call process cancellation operation. Third flow instance will be completed.
This is how the correlation set works.