« September 22, 2007 | Main | October 11, 2007 »

September 25, 2007 Archives

September 25, 2007

A Quick Response

A Quick Response

Returning an Immediate Response from an Asynch Process

I just got asked by a colleague how to return an immediate response from a BPEL process created using the template "Asynchronous BPEL Process".  Often we want to return some data to the caller of a process to indicate that the request has been received and is being processed.  To do this we need to add an immediate response to the caller in addition to calling them back later when the process is completed.  For example consider a process to make a booking for some resource.  The process might be lengthy and the caller may need some mechanism for canceling the process before it completes.  In this case returning an immediate response could give the caller a handle allowing him to call back into the specific process instance to cancel it.
So lets look at how we alter the template to allow for this immediate response.

Create the Project

First we create our process using File->New Project in JDeveloper and choose a BPEL PRocess Project and select the "Asynchronous BPEL Process" template.

Adding a Response Element

Once we have created our project we then need to add an immediate response element to the XSD.
    <element name="ImmediateResponseBPELProcessProcessImmediateResponse">
        <complexType>
            <sequence>
                <element name="result" type="string"/>
            </sequence>
        </complexType>
    </element>

Adding a New Message Type

Having created a new immediate response element to the XSD we then need to use that element within a new message type in the WSDL.
    <message name="ImmediateResponseBPELProcessImmediateResponseMessage">
        <part name="payload" element="client:ImmediateResponseBPELProcessProcessImmediateResponse"/>
    </message>

Adding an Output to the Initiate Operation

Within the port type for the process we need to modify the "initiate" operation to return an immediate response of the message type we just created.
        <operation name="initiate">
            <input message="client:ImmediateResponseBPELProcessRequestMessage"/>
            <output message="client:ImmediateResponseBPELProcessImmediateResponseMessage"/>
        </operation>

Adding a New Variable to the Process

We need to add a new variable to the process to hold the immediate return value.

Add a Reply to the Process

We can add the reply operation to the process and wire it up the client partner link.

Complete Process

Finally we need to complete the process.  I will often return the process instance ID as a return value.  This can then be used a correlation token if the client needs to call into the process again before it completes.

Once the process is finished being written it can be deployed and executed.

Remind Me Why Again

So adding an immediate response lets us confirm to the caller that we have received their request and also gives them a token to call back into the process later.  A complete example is uploaded here.  As you can see it is very easy to do and personally I feel all "asynchronous" processes should give some immediate response.

About September 2007

This page contains all entries posted to Antony Reynolds' Blog in September 2007. They are listed from oldest to newest.

September 22, 2007 is the previous archive.

October 11, 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle