Tuesday 15 December 2015

Asynchronous Vs Synchronous BPEL process

Asynchronous vs. Synchronous BPEL process

This article explains the difference between an asynchronous and a synchronous process.


I have tried to explain the difference with the help of a simple example below:

Suppose there are two processes SynchronousBPELProcess and AsynchronousBPELProcess. As the name suggest former one is a synchronous and later one is an asynchronous BPEL process. Also there is a third process which we’ll call as Client. The Client invokes the above processes.

Case 1: Client invokes SynchronousBPELProcess.
  1. Client invokes SynchronousBPELProcess.
  2. SynchronousBPELProcess gets instantiated and starts its operations while Client waits for the response from the SynchronousBPELProcess.
  3. SynchronousBPELProcess completes its operations and sends a response back to Client.
  4. Client continues and completes its processing.
Case 2: Client invokes AsynchronousBPELProcess
  1. Client invokes AsynchronousBPELProcess.
  2. AsynchronousBPELProcess gets instantiated and starts its operations while Client also continues to perform its operations.
  3. AsynchronousBPELProcess completes its operations and callback the Client with the response message.
Here we noticed that if a synchronous process is invoked, the operations of this process has to be completed first and only then the client is able to resume its operations while in the case of asynchronous both the process continues to perform their operations.


Fig1: An image showing bpel diagram of an asynchronous and a synchronous process.


What makes the difference?

Synchronous Process:

 The synchronous process defines one two way operation port to receive the request and send the response. Using the invokeactivity the client invokes the Synchronous BPEL process on this port and waits to receive the response on the same port. As soon as the client receives the response from the BPEL process it continues with its flow. On the BPEL process side, the Synchronous BPEL process gets instantiated on receiving the client request and sends back the reply using the reply activity on the same port on which the Client is waiting.

Asynchronous Process:

In the asynchronous process two one way operations ports are defined to receive the request and send the response. On the client side, the client uses the invoke activity to invoke the asynchronous BPEL process and continues with its flow. It uses the receive activity to receive the response later in the flow. The asynchronous BPEL process receives the request on one of the ports and sends back the reply from another port (callback port). To send the response the asynchronous BPEL process invokes the client on the callback port using the callback activity.




Fig 2: An image showing the wsdl of an asynchronous and a synchronous process.



Fig 3: An image showing a call to asynchronous and synchronous process.

We also find different operation names like initiate, onResult and process in the .bpel file. These are just labels to differentiate between sync and async processes.

* A port is nothing but a method with input and output. So a two way operation port has an input and an output while a one way operation port has only input or output.

********************************************************
1.When we can create synchronous bpel process
Synchronus process need to create in case if you are expecting reply Immediately.
ex. this is usefull in case if you are using Database adapter as partner link in BPEL process. Because database Adapter operation used to give reply immediately.

2. When we can create asynchronous bpel process
Asynchronus process need to create in case if you when reply will come is not having time limit.
Example:- Suppose if you have one loan process in which we are invoking some of the webservices(ex United Star Loan, HDFC loan) which will send the intrest charges in reply but in this case reply can come at any time. Till that time BPEL process need to wait for indefinite amount of time. If Sync BPEL process will be used in the above case then the BPEL process will time out and that will come under faulted state.

3.When we can create empty bpel process
Define Service Later: Select to create an empty BPEL process service component with no activities.

No comments:

Post a Comment