Introduction:
I have explained about synchronous BPEL process in my previous article. Now we will discuss about an example of asynchronous BPEL process. Asynchronous BPEL is one way process and does not wait for response for further processing.
We will see some difference between synchronous BPEL process and asynchronous BPEL process.
Synchronous and Asynchronous BPEL process can be defined based on their operational behavior. If triggering point of a BPEL process waits until a response returns from the same, then it can be recognized as synchronous process and if it continues with the other set of operations then the process will be asynchronous.
Synchronous BPEL process receives client request in one port and sends back reply using reply activity on the same port on which client is waiting. Asynchronous BPEL process receives the request on one of the ports and sends back the reply from another port (callback port).
Synchronous BPEL process has one invoke activity which will invoke the service. But asynchronous BPEL process invokes the service using invoke activity and replies back using receive activity.
Synchronous BPEL process has one reply activity. Callback activity only occurs in asynchronous BPEL process.
Provider role from WSDL is mapped to myRole attribute and requester role from WSDL is mapped to partnerRole attribute. Synchronous BPEL process supports provider role only.
Example:
I will go through the asynchronous activity using a�?Waita�? activity. Please follow the below steps.
- Create a SOA project. Right click on Application -> New -> Projects -> SOA projects. Enter project name as AsyncBPEL
- Click on NEXT button and select Composite With BPEL Process
- Click on FINISH button and BPEL Process Creation wizard will open. Enter the following details to set up BPEL process.Name = AsyncBPELProcessTemplate = Asynchronous BPEL ProcessInput and output message will be remain default value.Check the below screenshot also for further option
- Initially Asynchronous BPEL process will look like below screenshot. As it is an asynchronous BPEL process, callbackClient will be available instead of replyOutput.
- Select Assign activity from component palette and drag and drop it in between receiveInput and callbackClient. Drag and drop Wait activity also after Assign activity.
- Double click on Assign activity and add an expression. Click on Expression icon on the right upper side of the assign window.
- Add the below expression.
- Now assign window will look like this.
- Change the property of the Wait activity. Enter 30 seconds time in Wait activity. This will make the process to be waited for 30 seconds.
- Now the BPEL process will look like the below screenshot.
- Deploy the project and test it from EM console.
- Enter input string and click on Test Web Service. It will not display the output.
- Click on Launch Flow Trace and you will see that AsyncBPELProcess is still running. But the process has completed without waiting for wait process to complete.
- Wait for 30 seconds. After 30 seconds it will get completed.
- Click on AsyncBPELProcess instance and go to Flow tab to check the flow in the BPEL process.
- If you click on callbackClient, you will get the expected output.