WSO2 BPS - Sample Guide - Synchronous and Asynchronous Service Invocations

Sample Guide - Synchronous and Asynchronous Service Invocations

Table of Content


Explain how synchronous and asynchronous interactions can be handled via BPEL.

Let's understand what's meant by synchronous and asynchronous in BPEL terms. BPEL processes can also be categorized based on how it invokes an operation of a partner service: synchronous and asynchronous. However, it is not possible to use both methods when invoking a partner service's operation, as it is dependent on the type of partner service operation also.

Asynchronous interaction - Suppose a BPEL process invokes a partner service. After this invokation of the partner process, the BPEL process will continue to carry on with its execution process while that partner service completes performing its operation. The BPEL process will receive a response from the partner service, when the partner service is completed.

Synchronous interaction - Suppose a BPEL process invokes a partner service. The BPEL process then waits for the partner service's operation to be completed, and responded. After receiving this completion response from the partner service, the BPEL process will continue to carry on its execution flow. This transmission does not apply for the In-Only operations defined in the WSDL of the partner service.

Usually you'll use asynchronous services for long-lasting operations and synchronous services for operations that return a result in a relatively short time. Typically, when you use asynchronous Web services, the BPEL process too is asynchronous.

Let's take an example where there are both synchronous and asynchronous interactions. Suppose a loan approval process, where the client request for a loan with required documents. Then the service party first retrieve the customer information and his history using CustomerInfo service, then the service party calculate the credit rate using Credit rating service. Then service party finally send a request to DILoanService with previously retrieved the client history and the credit rating where the final decision from DILoanService may take a longer time. So we invoke DILoanService asynchronously.

Loan Approval Process

So what's the difference between Asynchronous and Synchronous interactions?

Here when invoking a service asynchronously, we need to define two roles(myRole and partnerRole) for the partner link. In a synchronous interaction only partnerRole is need to be defined.

These roles which are defined in partner link type. And they maps to particular port types. A partner link type binds two port types; port type process offers(myRole) to a partner and port type partner offers(partnerRole) to a process. In the above example DILoanService is invoked asynchronously and DILoanService has to provide aportType, which defines the partnerRole and another portType which definesmyRole.


Overall Idea