In this blog ,I wanna discuss how to create a pick activity to select
to continue a
process or wait, create wait activities to set an expiration time,
create
OnEvent branches in BPEL 1.0 to wait for message arrival, and set
timeouts on synchronous processes.
The pick activity provides two branches, each one with a condition. The
branch that has its condition satisfied first is executed
-
onMessage
This condition has code for receiving a reply in the form of a web service. The onMessage code matches the code for receiving a response from the web service before a timeout was added.
-
onAlarm
This condition has code for a timeout of one minute. This time is defined asPT1M
, which means to wait one minute before timing out. In this timeout setting:
-
S
stands for seconds -
M
for one minute -
H
for hour -
D
for day -
Y
for yearNote:The pick activity condition that completes first is the one that the BPEL process service component executes. The other branch then is not executed.
-
An onMessage branch is similar to a receive activity in that it receives
operations. However, you can define a pick activity with multiple
onMessage branches that can wait for similar partner links and port
types, but have different operations. Therefore, separate threads and
parallel processes can be invoked for each operation. This differs from
the receive activity in which there is only one operation. Another
difference is that you can create a new instance of a business process
with a receive activity (by selecting the Create Instance checkbox), but you cannot do this with a pick activity.
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
- An onMessage branch to receive the response (callback)
- An onAlarm branch to manage the timeout condition if it occurs before the response is
received
Create a BPEL project PICK_DemoPjct
Artifacts required is a simpleXSD : picksample.xsd
<xsd:element name="EmployeeDetails">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EmpID" type="xsd:string" />
<xsd:element name="Salary" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="EmpdetailsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EmpID" type="xsd:string" />
<xsd:element name="MessageStatus1" type="xsd:string" />
<xsd:element name="MessageStatus2" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EmpID" type="xsd:string" />
<xsd:element name="Salary" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="EmpdetailsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EmpID" type="xsd:string" />
<xsd:element name="MessageStatus1" type="xsd:string" />
<xsd:element name="MessageStatus2" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Step 1: Design the BPEL Process 1 name it "PickSyncBpelProcess" by selecting "SynchronousBPEL Process" as Template
Input,Output are the elements from the above picksample.xsd
Step 2: Design the BPEL Process 2 name it "PickAsyncBpelProcess" by selecting "ASynchronousBPEL Process" as Template
Input,Output are the elements from the above picksample.xsd
Note : Exposed as a soap Service is unchecked
Connect the BPEL process1 to BPEL process2 as shown below, design composite as below
Step 3: Now we will edit BPEL Process 2 "PickAsyncBpelProces"
In this Process Drop Assign activity between Receive and Callback and a delay
activity (Waiit_1) between Assign and Callback.Assign activity just assign input
to output.
Step 4: Now Configure the Wait activity to 5 seconds.It Means after Assign_1 activity there
will be a delay of 5 seconds
What happens when you create wait activity<wait (for="duration-expr" | until="deadline-expr")standard-attributes>standard-elements</wait>
in our case: <wait name="Wait1" for="'PT5S'"/>
the duration value bpelx:for="'PT5M'"
specifies that the activity expects an inbound message to arrive
no later than five minutesafter the activity has started execution.
Step 5: Now we will edit BPEL Process 1 "PickSyncBpelProces"
1. Add Invoke activity to Call BPEL Process 2 "PickAyncBpelProces"
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.
Create a Variable for Callback response to receive
reply from AsyncBpelprocess "PickAyncBpelProces"
3.Add Assign Activity Assign_1 with OnMessage branch and Assign activity Assign_1 with the OnAlarm activity.
4. In Assign_1 activity , assign MessageStatus1 element of "EmpdetailsResponse" of OutputMessageType with value 'OnMsg' and MessageStatus2 element with value 'BPEL_Pick'
5.In Assign_2 activity , assign MessageStatus1 element of "EmpdetailsResponse"
OutputMessageType with value 'On_ALARM' that indicate that it is Time out Activity.
6.Configure the OnAlarm activity of Pick activity and set the time = 59 seconds.That means if the OnMessage Branch has not been process within 59 seconds that BPEL will trigger the OnAlaram branch of theflow
6. Add Assign_3 to map input to invoke inputVariable of "PickAsyncBpelProces"
Step 6: Now our PICK_DemoPjct is ready to test
Run the BPEL Process .Please note that in BPEL Process we have a delay of 5
seconds and OnAlaram branch in Process1 will trigger only if OnMessage will not
get any response with in 59 seconds.
In Our case since
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 .
MessageStatus1 and MessageStatus2 value 'BPEL_Pick'
Step 7: Now we will tweet the code to test OnAlarm Branch
Once again configure the delay (Wait_1) activity of the BPEL process 2 and set
the dealy time = 2 minutes .That means Process2 will take 2 minutes of dealy
between Assign and callback.
Run the BPEL Process
By Deepthi Reddy
No comments:
Post a Comment