Step 3 - Creating the Correlation Set
With the loan approval process, in a practical scenario, there could be an issue with mapping the request/response. In a real-world scenario, there will be multiple clients sending their loan request to the BPEL process simultaneously. The same customer can send multiple loan requests as well. In a situation like this, how will the BPEL process map the different loan requests with their matching loan responses?
Consider the following questions:
How to map response1 to client A’s request1 instead of request2?
How to map response1 to client A’s request1 instead of client B’s request1?
The solution to this is to add a Correlation Set. Once you add a correlation to the BPEL process, it will map the different request-response pairs accordingly.
Considering the BPEL process created above, this issue occurs when the Asynchronous Process comes into place. At the receiveLoanOffer step, it needs to match the relevant loan response to the initial loan request. Therefore, follow the instructions in the below sections to create a Correlation Set for the Asynchronous Process of the scenario.
Let's get started! Follow the instructions in the below sections to add the Correlation Set to the below BPEL Workflow you created in Step2.
If you did not follow Step 2 - Creating the Asynchronous Process yet, you can import the pre-packaged project of it and continue by following the steps in this Tutorial. Follow the steps below to import it to WSO2 Integration Studio.
- Open the WSO2 Integration Studio, click File, and click Import.
- Expand the WSO2 category and select Existing WSO2 Projects into workspace, click Next and upload the pre-packaged project.
Also, if you are facing any problems with this Tutorial, you can import the pre-packaged project of this Tutorial to WSO2 Integration Studio, and compare your configurations with the ones in it.
Creating the Correlation Set
Follow the instructions below to add a correlation to this process.
- Click on the receiveInput element.
- In WSO2 Integration Studio under the BankLoanProcess menu, click the + sign on the Correlation Sets panel, to add a new correlation.
- Select the Correlation Set you created, and click Add in the Details section of its Properties tab.
- Click New in the Select a Property window.
- Enter id as the Name and click Browse.
- Select From Imports under Show XSD Types, select Simple Types and Complex Types under Filter, select the string XML Schema under the Matches and click OK.
- Click OK in the message, which pops up the set the prefix of the namespace.
Creating the first Alias of the Correlation Set
Click the New located next to the Aliases label in the Create Message Property window.
This maps the Correlation property you created to the matching property of the receiveInput request. This is to act as the alias for correlation.
- Select Message Type and click Browse.
Select From Project under Show XSD Types, select Messages under Filter.
Select BankLoanProcessRequestMessage under Matches, select CustomerID : CustomerIDType under Type Structure and click OK.
Click OK in the Create Property Alias window.
Creating the second Alias of the Correlation Set
Click the New located next to the Aliases label in the Create Message Property window.
This maps the Correlation property you created to the matching property of the receiveInput request. This is to act as the alias for correlation.
- Select Message Type and click Browse.
Select From Project under Show XSD Types, select Messages under Filter.
Select getLoanOfferResponse under Matches, select CustomerID : CustomerIDType under Type Structure and click OK.
Click OK in all the subsequent windows.
Mapping the Correlation to the request
- Click on the receiveInput element and click Add in the Correlation section of its Properties tab.
- Select Yes under the Initiation column for the correlation you added.
- Click on the ReceiveLoanOffer element and click Add in the Correlation section of its Properties tab.
- Select No under the Initiation column for the correlation you added.
Setting the ports of the Partner Links for deployment
- Double click on the
deploy.xml
file in the Package Explorer.
In the
deploy.xml
file, under Inbound Interfaces (Services), select the following values for each of the Partner Links, from the drop-down list of the Associated Port column.Partner Link Associated Port client BankLoanProcessPort LoanPL LoanServiceCallbackPort In the
deploy.xml
file, under Out bound Interfaces (Invokes), select the following values for each of the Partner Links, from the drop-down list of the Associated Port column.Partner Link Associated Port CustomerPL CustomerInfoPort CreditPL CreditRatingPort LoanPL LoanServicePort
Deploying the artifacts
- For instructions on creating the deployable artifacts, see Creating the deployable archive.
- For instructions on deploying them, see Deploying the BPEL Workflow.
Upload the following files by browsing them from the
<EI_HOME>/samples/business-process/bpel
directory, to deploy the three back-end services (i.e., CustomerInfoService, CreditRatingService, LoanService ), which are invoked from the BankLoanProcess.CustomerInfo.zip
CreditRating.zip
LoanService.zip
For instructions, see Deploying the BPEL Workflow.
Testing the output
- In the Management Console of the Business Process profile, click Main → Manage → Processes → List → BPEL, and click on the Process ID of the Bank Loan BPEL process you uploaded.
In the WSDL details section, select client as the Partner Link and click Try It.
You can now invoke it with input values.
- In the Request section of the Try It tool, replace the question marks with appropriate values for the Name, Email, Customer ID, Credit Rating, Amount and Number of Years.
- Click Send. You view the response in the Response section.