Friday, February 26, 2010

Pick Activity in BPEL

Pick activity is one of the most important activity in BPEL.It works on the principle that we have invoked a process and we are waiting for the results .Pick has two activity associated with it one is onMessage and other is onAlaram.

It works like we define a alram for the process if the response does not comes in the time period defined in alarm then it start executing the flow in the onAlarm scope and if the result comes before the expiration of onAlram then onMessage scope is followed.I will just provide a simple flow to understand the scenario.

First of all create a simple aysnchronous BPEL process which will be picked by our main BPEL process we will call this process as ToBePicked.





Drag and drop an assign activity and create a copy operation in assign activity where in map the input variable to the output variable.



Save and deploy the project.

Now again create a new asynchronous BPEL process give it some logical name i will call it Picker



Drag and drop a partnerlink and provide the WSDL of the ToBePicked process

So it should appear like



Now drag and drop a assign and a invoke activity in the process as below



Now select the invoke activity and drag and drop a connection from invoke to the partnerlink a pop up window will come up.click on create instance and create a instance as shown below.



Say apply and ok and you will find a link between the invoke and partnerlink as





Now double click on assign activity create a copy operataion and assign the input variable to the input of invoke.



Say apply and ok and now drag and drop a pick activity after the invoke activity





Now expand the pick activity fully and drag and drop assign activity in them as below




Now in the first assign activity just pass a value Arpit to the output variable.




Similarly create a copy operation in the second assign activity and assign value Ankit to the output variable.

Now double click on the watch icon and specify the time as 1 second



Again double click on the onMessage



A window will come up just click on the partner link choosing wizard.




and select the partnerlink that you have created earlier



Again click on the marked icon to create a default variable.




Say ok and save the project and deploy it.Now if you will check the process output you will get the following as output

<outputVariable>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
- <PickerProcessResponse xmlns="http://xmlns.oracle.com/Picker">

<result>

Arpit

</result>

</PickerProcessResponse>

</part>
</outputVariable>

This is because the process completed in milliseconds and entered the onMessage loop and exceuted the assign where in we are assigning the value Arpit to the output variable.

Now we will do some change in our ToBePicked process.We will add a wait activity there and give it a time period of 10 seconds and check how it behaves.

Add a wait activity by draggin and dropping it



now double click on wait activity and configure it for 10 seconds



Now deploy the process again .

Go to the Picker process and refresh the partnerlink to include the latest value of the ToBePicked process.

Now again deploy the Picker Process and invoke it.


now if you will review the output you will get

Your test request was processed synchronously. It took 1.094seconds to finish and generated the following output:
Value:
<PickerProcessResponsehttp://xmlns.oracle.com/Picker>
<result>Ankit</result>
</PickerProcessResponse>

The output will say

<outputVariable>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
- <PickerProcessResponse xmlns="http://xmlns.oracle.com/Picker">

<result>

Ankit

</result>

</PickerProcessResponse>

</part>
</outputVariable>

This is because the ToBePicked process took 10 seconds to complete and by that time the onAlaram gets activated since it is defined for 1 second so it start the execution Hence you got the time as 1.094seconds,the one second for the onAlaram and .094 for completion of the bpel process.

So now you can just imagine the speed of BPEL

No comments: