Friday, October 18, 2013

Learner Series: Oracle BPEL Receive & Pick Activity With Example

This post is part of the Oracle SOA BPEL learner series.

I have been getting lots of requests to write on basic SOA BPEL use-cases from my blog readers who are starting up on SOA initiatives. One such request that often comes across is the basic difference  between the usage of a pick and receive constructs in a BPEL process.

I have created a working BPEL use-case which contains both pick & receive activities in one SOA project.

A quick introduction to BPEL Pick & Receive Constructs;

Receive Activity: This is the first activity in most of the BPEL processes. As the name indicates, this construct receives information/message from a partner link.

Pick Activity: This activity is very similar to the receive construct. But unlike the receive activity which gets triggered only when a partner link invokes it, the Pick activity has 2 choices (On Message & On Alarm) - It waits for a message from a partner link or triggers another set of activities on timeout.

Use-Case: (Hypothetical but conveys the message)

A BPEL process (ReceivePick) gets a "Customer Name" as input, calls another BPEL process (CustomerCreditScoreWS) to get the customer's credit score. The CustomerCreditScoreWS process validates if the customer name starts with "A" and returns a credit rating immediately; else the process waits for 10 seconds before returning a blank response. The ReceivePick BPEL process waits for a message (credit score) from the CustomerCreditScoreWS process. If it gets a response (On Message: credit score), the process completes by returning a "Success" message; otherwise in the event of not getting a response for 8 seconds (On Alarm: 8 seconds) the process waits and terminates by returning a "Failure".

Receive-Pick BPEL Constructs at a glance
You can download the source code for this sample here