Bpel To Bpel Interaction With TimeOut
Let us discuss on how to interact from BPEL to BPEL with Timeout.
A client generates a requests to service and awaits till a reply is received or it reaches the time limit, whichever comes first.
In this Example – A BPEL process (Process1) client: uses an Invoke to send an asynchronous request to the service (BPEL Process 2), and a Pick activity with:
- An onMessage branch to receive the response (callback)
An onAlarm branch to manage the timeout condition if it occurs before the response is received.
Step # 1 – Drag and Drop the BPEL process and name them Process 1 and Process 2. Import the Message Type “OrderInfo” and assign them to Input and output variable, please refer my other blogs on BPEL fo further details on How to Import Message Type.
Step #2 – Design the BPEL Process 1.
- BPEL Process 1 is a Synchronous Process.
- Add Invoke activity to Call BPEL Process 2.
- Add Pick activity.Pickout activity has 2 type of outcome , OnMessage and OnAlarm. Set An onMessage branch to receive the response (callback) and an onAlarm branch to manage the timeout condition if it occurs before the response is received.
- Add Assign Activity Assign_2 with OnMessage branch and Assign activity Assign_3 with the OnAlarm activity.
- In Assign_2 activity , asign Satus element of “OrderInfo” MessageType with value ‘OnMsg’ and Status2 element with value ‘BP Pick’
- In Assign_2 activity , asign Satus element of “OrderInfo” MessageType with value ‘T Out’ that indicate that it is Time out Activity.
Step # 3 – Design BPEL Process 2.
In this process, Drop Assign activity between Receive and Callback and a delay activity (Wait_1) between Assign and Callback Assign activity, just assigns input to output.
Step # 4 – Configure the Wait activity to 5 seconds. It means after Assign_1 activity there will be a delay of 5 seconds.
Step # 5 – Configure OnMessage activity of BPEL Process 1 and set the BPEL Process 2 as partner link (it means, OnMessage activity in BPEL Process 1 will receive the call from the BPEL Process 2) and also associate the input variable as shown below.
Step # 6 – Configure the OnAlarm activity of Pick activity and set the tine = 59 seconds.In this case if the OnMessage Branch has not been process within 59 seconds, the BPEL will trigger the OnAlaram branch of the flow.
Step # 7 – Run the BPEL Process. Please note that in BPEL Process we have a delay of 5 seconds. OnAlaram branch in Process1 will trigger only if OnMessage does not get a response with in 59 seconds.
In our case since the delay in Process 2 is 5 seconds , On Message will get response in 5seconds and output will print the variable assign in Assign activity_2 .
Status = ‘OnMsg’ and Status2 = ‘BP Pick’
Step # 8 – Once again configure the delay (Wait_1) activity of the BPEL process 2 and set the delay time = 2 minutes .It means Process 2 will take 2 minutes of delay between Assign and Callback.
Run the BPEL Process.
Please note that in BPEL Process 1 we have a delay of 2 Minutes and OnAlaram branch in Process1 will trigger only if OnMessage does not get a response with in 59 seconds. In this case since Process 2 will take more than 2 minutes , On Alarm branch will Trigger .
As shown below(Input)
OutPut Status – TOut indicates that On Alarm branch is triggered.