Friday, February 26, 2010

Wait Activity in BPEL

Wait activity in BPEL is used to put an delay in processing of the bpel process.It is done intentionally in some cases.Lets assume some use cases, we have some process which needs to be invoked only after 10 seconds .In general bpel processing is very fast and a simple bpel process it it does not include and dehydration process the request in milli seconds.But in our case we need to wait to 10 seconds so we will put a wait activity in between so that our process can wait for 10 seconds before its get ready to be invoked.

Another reason for discussin wait activity here is the next topic i will be covering is about pick activity ,there we will find the proper use case for this.for now we will just creat a simple process and check how it delays the processing.

Create a new application and a new asynchronous BPEL process.Give it some logical name.



Now drag and drop a assign activity in between the input variable and the call back client.



Now double click on the assign activity create a copy opearation and assign the input varialbe to the output variable.



Now if you will deploy this process and try to invoke it you will get the response in milli seconds as bpel process server works in milliseconds but we don't want to get the output in milli seconds we want to delay for 10 seconds.In that case we will add a wait activity in there.Drag and drop a wait activity in between the input variable and the assign activity.




Now doule click on wait activity.


One important point that most of the people miss is that by default the wait time is specified as 1 day.SO when ever you are adding some time delay keep in mind that the wait is already set to 1 day so please make it zero or set it as per your requirement.In my case i want it to be delayed for 10 seconds so i will put the value as




Now apply the changes save the project and deploy it to the server.Once deployed invoke the process and you will get the response this time with some error.So you might get a screen like this



This is because the wait activity has not yet expired it will wait for its wait time that is 10 seconds and then only it will provide the result so we will just wait for few seconds and referesh the list so that we will get the following results after refreshing the flow.





There are some issues with wait activities that is it does not wake up on time this happens mostly in case of high loaded server.Again restart of server proceed this but you also need to fine tune your quartz scheduler settings to avoid this issue.

To fine tune it
Stop your server using opmnctl stopall
Now go to the following directory
SOA_HOME\bpel\domains\default\config\resources-quartz.properties

Take a backup of the file. and now edit the following value

com.oracle.bpel.expirationAgent.threadCount

By default it is set to 10 increase it to some higher value lets say 100.

Their are no documents or guidelines for setting this thread count.you just have to tweak its value and find out the best possible value for your environment.Once the changes are done.Save the changes and restart the server.

1 comment:

Anonymous said...

Hello,
Nice article there. Do you know how to wait in milliseconds?
Thanks