Step 2 - Creating the Asynchronous Process
If the loan approval process involves another process, in which the response takes too long to respond, you can use an Asynchronous Process to implement it. This allows you to continue the rest of the process flow without waiting for the response.
Let's get started! Follow the instructions in the below sections to complete the BPEL Workflow you created in Step1 with the As ynchronous Process as shown below.
If you did not follow Step 1 - Creating the Synchronous Processes 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.
Adding the Sequence element
Open the WSO2 EI Integration Studio.
Right click on the replyOutput element, click Insert Before and click Sequence.
Configuring the InvokeLoanService element
Right click on the Sequence element, click Add and click Invoke.
Click on the Invoke element you added inside the Sequence element, and enter InvokeLoanService as the Name in the Description section of the Properties tab.
Adding the Partner Link
Click on the InvokeLoanService element, click the drop-down arrow of Partner Link and select Create Global Partner Link. in the Details section of the Properties tab.
Enter LoanPL as the Partner Link Name and click OK .
Select From Project as the type of the Partner Link, select LoanServicePT in the Matches field and click OK .
Click OK in the message, which pops up next to set the prefix of the namespace.
Adding the Partner Role
Select the LoanServiceRole partner role and click OK .
Adding the Operation
Once the partner link is created, double click on the getLoanOffer operation from the Quick Pick view. This automatically updates the input request.
Configuring the ReceiveLoanOffer element
Right click on the Sequence element, click Add and click Receive.
Click on the Receive element you added inside the Sequence element, and enter ReceiveLoanOffer as the Name in the Description section of the Properties tab.
Adding the Partner Role
You need to use the OnLoanOffer operation of the LoanServiceCallBackPortType partner role for the ReceiveLoanOffer element. Therefore, follow the steps below to use the LoanPL partner link you created before for this ReceiveLoanOffer element as well.
In the Outline tab of WSO2 Integration Studio, click LoanPL under Partner Links.
Select the following values in the Details section of the Properties tab.
My Role:
LoanServiceClientRolePartner Role:
LoanServiceRoleMy Operations:
onLoanOfferPartner Operations:
getLoanOffer
Adding the Partner Link
Click on the ReceiveLoanOffer element, click the drop-down arrow of Partner Link and select LoanPL in the Details section of the Properties tab.
Adding the Operation
Keep your cursor on the Operation field and double-click on onLoanOffer.
This creates the LoanPLRequest1 variable.Double click on the LoanPLRequest1 variable and rename it to LoanPLResponse.
Configuring the Assign2 element
Right click on the Sequence element, click Insert Before and click Assign, to add the Assign2 element.
Mapping the variables
You need to map the required data received from the BankLoanProcessRequest message to the LoanPLRequest similar to the mapping you did before. Follow the steps below to do this.
Click on the Assign2 element and click New in the Details section of the Properties tab.
In the From box, expand the input : BankLoanProcessRequestMessage and select payload : LoanRequest.
In the To box, expand the LoanPLRequest : getLoanOfferRequest and select part : LoanRequest.
Press Ctrl+S to save your artifacts.
Click Yes in the message, which pops up to initialize the variables.
Follow the steps below to match the other variables.
Click New and select input: BankLoanProcessRequestMessage → payload : LoanRequest → CustomerInfo : CustomerInfo Type in the From box and select LoanPLRequest : getLoanOfferRequest → part : LoanRequest → CustomerInfo : CustomerInfo Type in the To box.
Press Ctrl+S to save the artifacts.
Click New and select input: BankLoanProcessRequestMessage → payload : LoanRequest → CustomerInfo : CustomerInfo Type → Name : string in the From box and select LoanPLRequest : getLoanOfferRequest → part : LoanRequest → CustomerInfo : CustomerInfo Type → Name : string in the To box.
Press Ctrl+S to save the artifacts.
Click New and select input: BankLoanProcessRequestMessage → payload : LoanRequest → CustomerInfo : CustomerInfo Type → Email : string in the From box and select LoanPLRequest : getLoanOfferRequest → part : LoanRequest → CustomerInfo : CustomerInfo Type → Email : string in the To box.
Press Ctrl+S to save the artifacts.
Click New and select input: BankLoanProcessRequestMessage → payload : LoanRequest → CustomerInfo : CustomerInfo Type → CustomerID : CustomerIDType in the From box and select LoanPLRequest : getLoanOfferRequest → part : LoanRequest → CustomerInfo : CustomerInfo Type → CustomerID : CustomerIDType in the To box.
Press Ctrl+S to save the artifacts.
Click New and select input: BankLoanProcessRequestMessage → payload : LoanRequest → CustomerInfo : CustomerInfo Type → CreditRating : int in the From box and select LoanPLRequest : getLoanOfferRequest → part : LoanRequest → CustomerInfo : CustomerInfo Type → CreditRating : int in the To box.
Press Ctrl+S to save the artifacts.
Configuring the Assign3 element
Follow the steps below to assign the values of the LoanPLResponse to the final output variable of the BPEL process.
Right click on the Sequence element, click Add and click Assign.