News

Stay up to date on the latest news from Rubicon Red. News, articles, customer success and press releases.

Oracle BPM Parallel Gateway with Multi-Instance processing and bpelx:copyList function

June 26, 2015

The Oracle BPM parallel gateway is very useful where the business process must perform multiple tasks in parallel.It can be combined with Multi-Instance loop markers to run a subprocess for each of the element on a set(or)array of data. But when combining these two features,there is a implicit rule with regards to the usage of copyList function and this blog aims at documenting it.

The sample use case is as follows:-

Consider the example of an Order entity with multiple Order Lines. The status of each order line determines the processing that needs to be done and once all the processing is complete, we require to merge the final outcome into the Order entity. The implementation pattern we will follow is to use the parallel gateway connecting different multi-instance sub-process each filtering their respective order lines by status and do the processing. Once everything is done they will converge at the outgoing parallel gateway.

Schema Definition - Order

   <!--?xml version= '1.0' encoding= 'UTF-8' ?> xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:qt="http://www.mycompany.com/ns/order" targetNamespace="http://www.mycompany.com/ns/order" elementFormDefault="qualified"> <annotation> xml:lang="en">Order </annotation> OrderType"/> orderLine" type="qt:OrderLineType"/> <complexType name="OrderType"> <sequence> orderID" type="string"/> customerName" type="string"/> customerAddress" type="string"/> orderLine" maxOccurs="unbounded" minOccurs="0" type="qt:OrderLineType"/> </sequence> <!--complexType> <xsd:complexType name="OrderLineType"> <xsd:sequence> <xsd:element name="orderLineID" maxOccurs="1" type="xsd:string"/> <xsd:element name="itemId" maxOccurs="1" type="xsd:string"/> <xsd:element name="quantity" maxOccurs="1" type="xsd:int"/> <xsd:element name="status" maxOccurs="1" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </schema>  

Lets create a simple business process to model the above mentioned usecase:

bpm_issue1

Add the 'order' element as the input to the bpmn process

bpm_issue2

Complete the association between the input data and the process data object -'order':

bpm_issue3

Below is the modeled business process for the use case. The process takes two parallel gateway paths to process approved & pending orders separately. Once the processing is complete, the outcome is merged to the order entity.

bpm_issue4

bpm_issue5

Configure each sub-process to filter only their respective order lines. An example for Pending Orders is shown below:

bpm_issue6

XPATH expression to filter the pending order lines is shown below(we need to put the expression for both input & output loop data output) -

bpm_issue7

Do the above for approved order lines and deploy the business process.

Let's test the business process using two test cases :

Testcase 1 : Contains the payload with Order lines sorted by 'status'

Testcase 2 : Contains the payload with Order lines unsorted by 'status'

Testcase 1:

  1. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  2.  <soap:Body>
  3.   <ns1:start
  4.    xmlns:ns1="http://xmlns.oracle.com/bpmn/bpmnProcess/MultiInstanceProcess"
  5.    xmlns:ns2="http://www.mycompany.com/ns/order">
  6.    <ns2:order>
  7.     <ns2:orderID>1</ns2:orderID>
  8.     <ns2:customerName>Ganesh</ns2:customerName>
  9.     <ns2:customerAddress>Melbourne</ns2:customerAddress>
  10.     <ns2:orderLine>
  11.      <ns2:orderLineID>100</ns2:orderLineID>
  12.      <ns2:itemId>10</ns2:itemId>
  13.      <ns2:quantity>2</ns2:quantity>
  14.      <ns2:status>APPROVED</ns2:status>
  15.     </ns2:orderLine>
  16.     <ns2:orderLine>
  17.      <ns2:orderLineID>101</ns2:orderLineID>
  18.      <ns2:itemId>33</ns2:itemId>
  19.      <ns2:quantity>1</ns2:quantity>
  20.      <ns2:status>APPROVED</ns2:status>
  21.     </ns2:orderLine>
  22.     <ns2:orderLine>
  23.      <ns2:orderLineID>102</ns2:orderLineID>
  24.      <ns2:itemId>34</ns2:itemId>
  25.      <ns2:quantity>10</ns2:quantity>
  26.      <ns2:status>PENDING</ns2:status>
  27.     </ns2:orderLine>
  28.    </ns2:order>
  29.   </ns1:start>
  30.  </soap:Body>
  31. </soap:Envelope>

The process completes successfully and below shows the audit trail for that.

bpm_issue8

Now let's try the other test case:

Testcase 2 :

  1. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  2.  <soap:Body>
  3.   <ns1:start
  4.    xmlns:ns1="http://xmlns.oracle.com/bpmn/bpmnProcess/MultiInstanceProcess"
  5.    xmlns:ns2="http://www.mycompany.com/ns/order">
  6.    <ns2:order>
  7.     <ns2:orderID>1</ns2:orderID>
  8.     <ns2:customerName>Ganesh</ns2:customerName>
  9.     <ns2:customerAddress>Melbourne</ns2:customerAddress>
  10.     <ns2:orderLine>
  11.      <ns2:orderLineID>101</ns2:orderLineID>
  12.      <ns2:itemId>33</ns2:itemId>
  13.      <ns2:quantity>1</ns2:quantity>
  14.      <ns2:status>APPROVED</ns2:status>
  15.     </ns2:orderLine>
  16.     <ns2:orderLine>
  17.      <ns2:orderLineID>102</ns2:orderLineID>
  18.      <ns2:itemId>34</ns2:itemId>
  19.      <ns2:quantity>10</ns2:quantity>
  20.      <ns2:status>PENDING</ns2:status>
  21.     </ns2:orderLine>
  22.     <ns2:orderLine>
  23.      <ns2:orderLineID>100</ns2:orderLineID>
  24.      <ns2:itemId>10</ns2:itemId>
  25.      <ns2:quantity>2</ns2:quantity>
  26.      <ns2:status>APPROVED</ns2:status>
  27.     </ns2:orderLine>
  28.    </ns2:order>
  29.   </ns1:start>
  30.  </soap:Body>
  31. </soap:Envelope>

The process fails with the below error:

bpm_issue9

Error Message: {http://docs.oasis-open.org/wsbpel/2.0/process/executable}mismatchedAssignmentFailure

Fault ID

default/MultiInstanceProcess!1.0*soa_00de7c84-1a46-4324-a7f2-2071ef7a680f/MultiInstanceProcess/830003-ACT10651136503013MultiInstanceBlock_ACT10651136503013_End-ACT10651136503013MultiInstanceBlock_ACT10651136503013.3-2

Fault Time

Non Recoverable System Fault :

<bpelFault><faultType>0</faultType><mismatchedAssignmentFailure xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"></mismatchedAssignmentFailure></bpelFault>

The issue is because BPM internally uses an function similar to the bpelx:copyList to copy the nodes and unless the list used to filter the status are contiguous, the above pattern will not work. To workaround the issue, we need to explicitly sort the order lines by status before passing it through the parallel gateway.

From documentation -

http://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_manipdoc.htm#CIHICJGH

6.14.6.1 bpelx:copyList in BPEL 1.1

Example 6-65 provides an example of bpelx:copyList in a BPEL project that supports BPEL version 1.1.

Example 6-65 bpelx:copyList Extension in BPEL 1.1

<bpel:assign>

<bpelx:copyList>

<bpelx:from ... />

<bpelx:to ... />

</bpelx:copyList>

</bpel:assign>

The from-spec query can yield a list of either all attribute nodes or all element nodes. The to-spec query can yield a list of L-value nodes: either all attribute nodes or all element nodes.

All the element nodes returned by the to-spec query must have the same parent element. If the to-spec query returns a list of element nodes, all element nodes must be contiguous.