Today I found a good material on Reynolds blog. This says about how to return an immediate response from a BPEL process created using "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. The process is attached at the bottom of this post.
So lets look at how we alter the template.
So lets look at how we alter the template.
Creating 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. Name the process as "ImmediateResponseBPELProcess".
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.
Adding a Reply to the Process: We can add the reply operation to the process and wire it up the client partner link.
Full 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.
At the End: So adding an immediate responsetells 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.
1 comment:
i think this is changing from sync to async..
Post a Comment