Custom Search SOABYTE here

Monday, November 8, 2010

How do I guarantee ordering of messages processed by FileAdapter and BPEL

Even if you publish messages from the FileAdapter in a certain order, it does not guarantee the order in which BPEL would process these messages. In order to maintain message ordering, you will need to do the following:

i) Set oracle.tip.adapter.file.numProcessorThreads=1 (see FAQ entry "How do I configure number of threads for FileAdapter")
ii) Model the BPEL process as a synchronous FileAdapter BPEL process:
Normally the File adapter wizard only creates OneWay WSDLs so you will have to manually tweak it a little, i.e. modifying the generated WSDL so it becomes a Request-Response type WSDL with input and output messages.
For example:
Lets first create a XML schema type for the (dummy) Response (output) message.
  <schema xmlns=""
     <import namespace="" schemaLocation="FileSchema.xsd" />
     <element name="empty">
Then we define the WSDL message:
<message name="ignore_msg">
  <part name="empty" element="file:empty"/>
Now we can add an output message to the file read operation:
<portType name="Read_ptt">
  <operation name="Read">
    <input message="tns:records_msg"/>
    <output message="tns:ignore_msg"/>
We also need to add an output element in the binding section:
<binding name="Read_binding" type="tns:Read_ptt">
  <pc:inbound_binding />
  <operation name="Read">
    <jca:operation .../>
      <jca:header message="hdr:InboundHeader_msg" part="inboundHeader"/>
Now the WSDL is OK.
In the BPEL Process you simply add a Reply activity as shown:
  <variable name="ignore" messageType="ns1:ignore_msg"/>
  <correlationSet name="dummy" properties="ns1:dummy"/>
<sequence name="main">
  <receive partnerLink="FileReader" portType="ns1:Read_ptt" operation="Read"
           variable="Receive_1_Read_InputVariable" createInstance="yes">
      <correlation initiate="yes" set="dummy"/>
  [...]  <!-- processing -->
  <invoke partnerLink="...."/>
  <invoke partnerLink="...."/>
  <reply partnerLink="FileReader" portType="ns1:Read_ptt" operation="Read" variable="ignore"/>
  [...]  <!-- optionally more processing -->
Notice the use of a Correlation set on the Receive activity, which is needed establish/determine the FileReader partnerlink conversation ID. The Correlation property can be defined in the file read WSDL, e.g.
    <bpws:property name="dummy" type="xsd:string"/>
    <bpws:propertyAlias propertyName="tns:dummy"
       messageType="tns:records_msg" part="..." query="..."/>
Thus using a synchronous flow will guarantee ordering between the Receive and the Invoke right before the (first) Reply. Note - the process can still continue after the Reply if need be.


Post a Comment

Blogger Profile