In my previous post, I explained about pick activity and also
explained where we can use this activity in BPEL. Below are the two scenarios
where we can use pick activity.
- When we call asynchronous service and we need response back in certain time frame otherwise we need to throw exception.
- When we want to have multiple entry point for any composite. E.g. when we want our process when it is invoked by client or when any message is put to JMS queue by client.
In This post, I will discuss about first scenario and
show one use case of that.
In this scenario, we call one asynchronous service which provides
response in certain time frame, if that service is not able to provide the
response in that time period then we need to throw time out error and stop the
processing.
First create an asynchronous service and deploy it to SOA
server.
Now create a new composite and add BPEL component to it. From this composite, we call asynchronous
service so we need to add asynchronous service reference in the composite, once
asynchronous service reference is added, wire it to BPEL.
Now open your BPEL process and add “Invoke” activity
inside it to call asynchronous service.
Add a pick activity after the Invoke; this pick activity
has two branches. First branch is “OnMessage” and other is “OnAlarm”. Click on
Pick activity and add “OnAlarm” branch also.
Make sure that “Create Instance” box in unchecked for
pick activity as we don’t want to create any instance, we just want to get the
response back from asynchronous service.
Let’s first talk about OnMessage branch, this branch is used to get the response from asynchronous service. This branch act like a receive activity. Click on OnMessage branch and choose the reference service partner link.
In OnAlarm branch, we specify the expiration time which means
if we get the response from asynchronous service within specified time then
control will go to OnMessage branch and we successfully retrieve the message
and if asynchronous response time exceeds specified time than control will go
to OnAlram and whatever activities we have added there will execute.
Now deploy this composite and we test both OnMessage and
OnAlarm branch.
Let’s first test OnMessage branch, as shown in below screen shot, asynchronous service provided the response within specified time limit so control goes to OnMessage branch.
Now let’s test OnAlarm branch. For this we have added
some wait inside asynchronous service so that when first composite call
asynchronous service, asynchronous takes more than specifies time.
By Vivek Garg - 6/27/2014
Please do not copy content of this post to your blog.
0 comments :
Post a Comment