cancel
Showing results for 
Search instead for 
Did you mean: 

Compensation in Parallel Tasks

gokceng1
Champ in-the-making
Champ in-the-making
I couldn't understand compensation in parallel execution. You can see the here here and XML here:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://sourceforge.net/bpmn/definitions/_1354022728531" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:yaoqiang="http://bpmn.sourceforge.net" exporter="Yaoqiang BPMN Editor" exporterVersion="2.1.11" expressionLanguage="http://www.w3.org/1999/XPath" id="_1354022728531" name="" targetNamespace="http://sourceforge.net/bpmn/definitions/_1354022728531" typeLanguage="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://bpmn.sourceforge.net/schemas/BPMN20.xsd">
  <process id="PROCESS_1" isClosed="false" isExecutable="true" processType="None">
    <startEvent id="_2" isInterrupting="true" name="Start Event" parallelMultiple="false">
      <outgoing>_4</outgoing>
    </startEvent>
    <scriptTask completionQuantity="1" id="_3" isForCompensation="false" name="Script Task1" scriptFormat="groovy" startQuantity="1">
      <incoming>_4</incoming>
      <outgoing>_36</outgoing>
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_4" sourceRef="_2" targetRef="_3"/>
    <parallelGateway gatewayDirection="Unspecified" id="_5" name="Parallel Gateway">
      <incoming>_37</incoming>
      <outgoing>_8</outgoing>
      <outgoing>_10</outgoing>
    </parallelGateway>
    <scriptTask completionQuantity="1" id="_7" isForCompensation="false" name="Script Task2" scriptFormat="groovy" startQuantity="1">
      <incoming>_8</incoming>
      <outgoing>_12</outgoing>
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_8" sourceRef="_5" targetRef="_7"/>
    <scriptTask completionQuantity="1" id="_9" isForCompensation="false" name="Script Task3" scriptFormat="groovy" startQuantity="1">
      <incoming>_10</incoming>
      <outgoing>_16</outgoing>
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_10" sourceRef="_5" targetRef="_9"/>
    <intermediateThrowEvent id="_11" name="Intermediate Throw Event">
      <incoming>_12</incoming>
      <outgoing>_14</outgoing>
      <compensateEventDefinition id="_11_ED_1" waitForCompletion="true"/>
    </intermediateThrowEvent>
    <sequenceFlow id="_12" sourceRef="_7" targetRef="_11"/>
    <parallelGateway gatewayDirection="Unspecified" id="_13" name="Parallel Gateway">
      <incoming>_14</incoming>
      <incoming>_17</incoming>
      <outgoing>_19</outgoing>
    </parallelGateway>
    <sequenceFlow id="_14" sourceRef="_11" targetRef="_13"/>
    <intermediateThrowEvent id="_15" name="Intermediate Throw Event">
      <incoming>_16</incoming>
      <outgoing>_17</outgoing>
      <compensateEventDefinition id="_15_ED_1" waitForCompletion="true"/>
    </intermediateThrowEvent>
    <sequenceFlow id="_16" sourceRef="_9" targetRef="_15"/>
    <sequenceFlow id="_17" sourceRef="_15" targetRef="_13"/>
    <scriptTask completionQuantity="1" id="_18" isForCompensation="false" name="Script Task4" scriptFormat="groovy" startQuantity="1">
      <incoming>_19</incoming>
      <outgoing>_21</outgoing>
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_19" sourceRef="_13" targetRef="_18"/>
    <intermediateThrowEvent id="_20" name="Intermediate Throw Event">
      <incoming>_21</incoming>
      <outgoing>_23</outgoing>
      <compensateEventDefinition id="_20_ED_1" waitForCompletion="true"/>
    </intermediateThrowEvent>
    <sequenceFlow id="_21" sourceRef="_18" targetRef="_20"/>
    <endEvent id="_22" name="End Event">
      <incoming>_23</incoming>
    </endEvent>
    <sequenceFlow id="_23" sourceRef="_20" targetRef="_22"/>
    <boundaryEvent attachedToRef="_3" cancelActivity="true" id="_24" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_24_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <boundaryEvent attachedToRef="_7" cancelActivity="true" id="_25" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_25_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <boundaryEvent attachedToRef="_9" cancelActivity="true" id="_26" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_26_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <boundaryEvent attachedToRef="_18" cancelActivity="true" id="_27" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_27_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <scriptTask completionQuantity="1" id="_28" isForCompensation="true" name="Compensation Script Task2" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <scriptTask completionQuantity="1" id="_30" isForCompensation="true" name="Compensation Script Task3" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <scriptTask completionQuantity="1" id="_32" isForCompensation="true" name="Compensation Script Task4" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <scriptTask completionQuantity="1" id="_34" isForCompensation="true" name="Compensation Script Task1" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[out:println execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <intermediateThrowEvent id="_6" name="Intermediate Throw Event">
      <incoming>_36</incoming>
      <outgoing>_37</outgoing>
      <compensateEventDefinition id="_6_ED_1" waitForCompletion="true"/>
    </intermediateThrowEvent>
    <sequenceFlow id="_36" sourceRef="_3" targetRef="_6"/>
    <sequenceFlow id="_37" sourceRef="_6" targetRef="_5"/>
    <association associationDirection="One" id="_29" sourceRef="_25" targetRef="_28"/>
    <association associationDirection="One" id="_31" sourceRef="_26" targetRef="_30"/>
    <association associationDirection="One" id="_33" sourceRef="_27" targetRef="_32"/>
    <association associationDirection="One" id="_35" sourceRef="_24" targetRef="_34"/>
  </process>
  <bpmndi:BPMNDiagram documentation="background=#FFFFFF;count=1;horizontalcount=1;orientation=0;width=597.6;height=842.4;imageableWidth=587.6;imageableHeight=832.4;imageableX=5.0;imageableY=5.0" id="Yaoqiang_Diagram-_1" name="New Diagram">
<!– Excluded –>
  </bpmndi:BPMNDiagram>
</definitions>

Execution order of this process:
Script Task1
Compensation Script Task1
Script Task2
Script Task3
Script Task4
Compensation Script Task4
Compensation Script Task3
Compensation Script Task2

What I didn't understand is why Intermediate Compensation Throw Events after Script 2 and Script 3 didn't cause trigger Compensation Script Task3, Compensation Script Task2?

In short, why does process wait for compensation event which is after Script Task 4?
12 REPLIES 12

gokceng1
Champ in-the-making
Champ in-the-making
I've just changed id of process:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://sourceforge.net/bpmn/definitions/_1354022728531" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:yaoqiang="http://bpmn.sourceforge.net" exporter="Yaoqiang BPMN Editor" exporterVersion="2.1.11" expressionLanguage="http://www.w3.org/1999/XPath" id="_1354022728531" name="" targetNamespace="http://sourceforge.net/bpmn/definitions/_1354022728531" typeLanguage="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://bpmn.sourceforge.net/schemas/BPMN20.xsd">
  <process id="parallelCompensationProcess" isExecutable="true" name="parallelCompensationProcess" processType="None">
    <startEvent id="_2" isInterrupting="true" name="Start Event" parallelMultiple="false">
      <outgoing>_4</outgoing>
    </startEvent>
    <scriptTask completionQuantity="1" id="_3" isForCompensation="false" name="Script Task1" scriptFormat="groovy" startQuantity="1">
      <incoming>_4</incoming>
      <outgoing>_36</outgoing>
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_4" sourceRef="_2" targetRef="_3"/>
    <parallelGateway gatewayDirection="Unspecified" id="_5" name="Parallel Gateway">
      <incoming>_37</incoming>
      <outgoing>_8</outgoing>
      <outgoing>_10</outgoing>
    </parallelGateway>
    <scriptTask completionQuantity="1" id="_7" isForCompensation="false" name="Script Task2" scriptFormat="groovy" startQuantity="1">
      <incoming>_8</incoming>
      <outgoing>_12</outgoing>
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_8" sourceRef="_5" targetRef="_7"/>
    <scriptTask completionQuantity="1" id="_9" isForCompensation="false" name="Script Task3" scriptFormat="groovy" startQuantity="1">
      <incoming>_10</incoming>
      <outgoing>_16</outgoing>
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_10" sourceRef="_5" targetRef="_9"/>
    <intermediateThrowEvent id="_11" name="Intermediate Throw Event">
      <incoming>_12</incoming>
      <outgoing>_14</outgoing>
      <compensateEventDefinition id="_11_ED_1" waitForCompletion="false"/>
    </intermediateThrowEvent>
    <parallelGateway gatewayDirection="Unspecified" id="_13" name="Parallel Gateway">
      <incoming>_14</incoming>
      <incoming>_17</incoming>
      <outgoing>_19</outgoing>
    </parallelGateway>
    <sequenceFlow id="_14" sourceRef="_11" targetRef="_13"/>
    <intermediateThrowEvent id="_15" name="Intermediate Throw Event">
      <incoming>_16</incoming>
      <outgoing>_17</outgoing>
      <compensateEventDefinition id="_15_ED_1" waitForCompletion="false"/>
    </intermediateThrowEvent>
    <sequenceFlow id="_16" sourceRef="_9" targetRef="_15"/>
    <sequenceFlow id="_17" sourceRef="_15" targetRef="_13"/>
    <scriptTask completionQuantity="1" id="_18" isForCompensation="false" name="Script Task4" scriptFormat="groovy" startQuantity="1">
      <incoming>_19</incoming>
      <outgoing>_21</outgoing>
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_19" sourceRef="_13" targetRef="_18"/>
    <intermediateThrowEvent id="_20" name="Intermediate Throw Event">
      <incoming>_21</incoming>
      <outgoing>_23</outgoing>
      <compensateEventDefinition id="_20_ED_1" waitForCompletion="true"/>
    </intermediateThrowEvent>
    <sequenceFlow id="_21" sourceRef="_18" targetRef="_20"/>
    <endEvent id="_22" name="End Event">
      <incoming>_23</incoming>
    </endEvent>
    <sequenceFlow id="_23" sourceRef="_20" targetRef="_22"/>
    <boundaryEvent attachedToRef="_3" cancelActivity="true" id="_24" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_24_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <boundaryEvent attachedToRef="_7" cancelActivity="true" id="_25" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_25_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <boundaryEvent attachedToRef="_9" cancelActivity="true" id="_26" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_26_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <boundaryEvent attachedToRef="_18" cancelActivity="true" id="_27" name="Boundary Event" parallelMultiple="false">
      <compensateEventDefinition id="_27_ED_1" waitForCompletion="true"/>
    </boundaryEvent>
    <scriptTask completionQuantity="1" id="_28" isForCompensation="true" name="Compensation Script Task2" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <scriptTask completionQuantity="1" id="_30" isForCompensation="true" name="Compensation Script Task3" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <scriptTask completionQuantity="1" id="_32" isForCompensation="true" name="Compensation Script Task4" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <scriptTask completionQuantity="1" id="_34" isForCompensation="true" name="Compensation Script Task1" scriptFormat="groovy" startQuantity="1">
      <script><![CDATA[outSmiley Tonguerintln execution.getCurrentActivityName();]]></script>
    </scriptTask>
    <sequenceFlow id="_12" sourceRef="_7" targetRef="_11"/>
    <sequenceFlow id="_37" sourceRef="_6" targetRef="_5"/>
    <sequenceFlow id="_36" sourceRef="_3" targetRef="_6"/>
    <intermediateThrowEvent id="_6" name="Intermediate Throw Event">
      <incoming>_36</incoming>
      <outgoing>_37</outgoing>
      <compensateEventDefinition id="_6_ED_1" waitForCompletion="true"/>
    </intermediateThrowEvent>
    <association associationDirection="One" id="_29" sourceRef="_25" targetRef="_28"/>
    <association associationDirection="One" id="_31" sourceRef="_26" targetRef="_30"/>
    <association associationDirection="One" id="_33" sourceRef="_27" targetRef="_32"/>
    <association associationDirection="One" id="_35" sourceRef="_24" targetRef="_34"/>
  </process>
  <bpmndi:BPMNDiagram documentation="background=#FFFFFF;count=1;horizontalcount=1;orientation=0;width=597.6;height=842.4;imageableWidth=587.6;imageableHeight=832.4;imageableX=5.0;imageableY=5.0" id="Yaoqiang_Diagram-_1" name="New Diagram">
    <bpmndi:BPMNPlane bpmnElement="parallelCompensationProcess">
      <bpmndi:BPMNShape bpmnElement="_2" id="Yaoqiang-_2">
        <dc:Bounds height="32.0" width="32.0" x="-12.150793650793545" y="253.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_3" id="Yaoqiang-_3">
        <dc:Bounds height="65.0" width="95.0" x="65.52380952380958" y="236.8571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="65.0" width="95.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_5" id="Yaoqiang-_5">
        <dc:Bounds height="42.0" width="42.0" x="354.65873015873024" y="248.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="42.0" width="42.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_7" id="Yaoqiang-_7">
        <dc:Bounds height="65.0" width="95.0" x="443.2063492063493" y="119.95238095238102"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="65.0" width="95.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_9" id="Yaoqiang-_9">
        <dc:Bounds height="65.0" width="95.0" x="443.2063492063493" y="368.26984126984127"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="65.0" width="95.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_11" id="Yaoqiang-_11">
        <dc:Bounds height="32.0" width="32.0" x="624.1825396825396" y="157.45238095238102"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_13" id="Yaoqiang-_13">
        <dc:Bounds height="42.0" width="42.0" x="621.7063492063492" y="248.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="42.0" width="42.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_15" id="Yaoqiang-_15">
        <dc:Bounds height="32.0" width="32.0" x="624.1825396825396" y="384.76984126984127"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_18" id="Yaoqiang-_18">
        <dc:Bounds height="61.35714285714283" width="95.0" x="730.0793650793651" y="238.67857142857144"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="61.35714285714283" width="95.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_20" id="Yaoqiang-_20">
        <dc:Bounds height="32.0" width="32.0" x="885.0079365079364" y="253.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_22" id="Yaoqiang-_22">
        <dc:Bounds height="32.0" width="32.0" x="963.4047619047617" y="253.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_28" id="Yaoqiang-_28">
        <dc:Bounds height="55.0" width="85.0" x="448.2063492063493" y="236.77777777777783"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_30" id="Yaoqiang-_30">
        <dc:Bounds height="55.0" width="85.0" x="448.2063492063493" y="493.2857142857142"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_32" id="Yaoqiang-_32">
        <dc:Bounds height="55.0" width="85.0" x="729.9206349206349" y="337.09523809523813"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_34" id="Yaoqiang-_34">
        <dc:Bounds height="55.0" width="85.0" x="70.87301587301596" y="358.6825396825397"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_6" id="Yaoqiang-_6">
        <dc:Bounds height="32.0" width="32.0" x="251.00793650793662" y="253.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_24" id="Yaoqiang-_24">
        <dc:Bounds height="32.0" width="32.0" x="98.18253968253978" y="285.8571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="1.0" x="32.65873015873021" y="-16.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_25" id="Yaoqiang-_25">
        <dc:Bounds height="32.0" width="32.0" x="461.7539682539683" y="168.95238095238102"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="1.0" x="18.547619047619037" y="-16.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_26" id="Yaoqiang-_26">
        <dc:Bounds height="32.0" width="32.0" x="477.436507936508" y="417.26984126984127"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="1.0" x="34.230158730158735" y="-16.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_27" id="Yaoqiang-_27">
        <dc:Bounds height="32.0" width="32.0" x="758.4999999999999" y="284.0357142857143"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="1.0" x="28.420634920634825" y="-16.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_23" id="Yaoqiang-_23" sourceElement="_20" targetElement="_22">
        <di:waypoint x="917.3894691211514" y="269.3571428571429"/>
        <di:waypoint x="963.4710362771165" y="269.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_21" id="Yaoqiang-_21" sourceElement="_18" targetElement="_20">
        <di:waypoint x="825.251992911047" y="269.35714285714283"/>
        <di:waypoint x="884.4917720626487" y="269.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_8" id="Yaoqiang-_8" sourceElement="_5" targetElement="_7">
        <di:waypoint x="374.0" y="249.8747375493407"/>
        <di:waypoint x="374.0" y="213.0"/>
        <di:waypoint x="443.5180446076138" y="152.45238095238102"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_19" id="Yaoqiang-_19" sourceElement="_13" targetElement="_18">
        <di:waypoint x="663.849815144527" y="269.3571428571429"/>
        <di:waypoint x="729.8185058351886" y="269.35714285714283"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_17" id="Yaoqiang-_17" sourceElement="_15" targetElement="_13">
        <di:waypoint x="644.0" y="384.809543524465"/>
        <di:waypoint x="644.0" y="331.0"/>
        <di:waypoint x="644.0" y="288.6979883825796"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_16" id="Yaoqiang-_16" sourceElement="_9" targetElement="_15">
        <di:waypoint x="537.8545950504163" y="400.7698412698413"/>
        <di:waypoint x="624.512737620285" y="400.7698412698412"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_4" id="Yaoqiang-_4" sourceElement="_2" targetElement="_3">
        <di:waypoint x="20.095476647025237" y="269.3571428571429"/>
        <di:waypoint x="65.0749062033482" y="269.35714285714295"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_14" id="Yaoqiang-_14" sourceElement="_11" targetElement="_13">
        <di:waypoint x="644.0" y="188.72363706630054"/>
        <di:waypoint x="644.0" y="207.0"/>
        <di:waypoint x="644.0" y="249.71913205592062"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_12" id="Yaoqiang-_12" sourceElement="_7" targetElement="_11">
        <di:waypoint x="537.8545950504163" y="141.0"/>
        <di:waypoint x="644.0" y="141.0"/>
        <di:waypoint x="644.0" y="157.7295725874273"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_10" id="Yaoqiang-_10" sourceElement="_5" targetElement="_9">
        <di:waypoint x="376.0" y="289.5583296054627"/>
        <di:waypoint x="376.0" y="336.0"/>
        <di:waypoint x="443.5180446076138" y="400.7698412698413"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_37" id="Yaoqiang-_37" sourceElement="_6" targetElement="_5">
        <di:waypoint x="283.3602685804274" y="269.3571428571429"/>
        <di:waypoint x="354.8147599679833" y="269.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_36" id="Yaoqiang-_36" sourceElement="_3" targetElement="_6">
        <di:waypoint x="160.50839327920647" y="269.35714285714295"/>
        <di:waypoint x="251.55916142387485" y="269.3571428571429"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_29" id="Yaoqiang-_29" sourceElement="_25" targetElement="_28">
        <di:waypoint x="477.7539682539684" y="201.19531815519647"/>
        <di:waypoint x="477.7539682539684" y="236.30046122757483"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_35" id="Yaoqiang-_35" sourceElement="_24" targetElement="_34">
        <di:waypoint x="114.18253968253975" y="317.47105554527735"/>
        <di:waypoint x="114.18253968253975" y="359.1573641298292"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_33" id="Yaoqiang-_33" sourceElement="_27" targetElement="_32">
        <di:waypoint x="774.4999999999999" y="316.37478221802894"/>
        <di:waypoint x="774.4999999999999" y="337.2186314687123"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_31" id="Yaoqiang-_31" sourceElement="_26" targetElement="_30">
        <di:waypoint x="493.43650793650806" y="449.10616610498835"/>
        <di:waypoint x="493.43650793650806" y="492.98363336264197"/>
        <bpmndi:BPMNLabel>
          <dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

And the test code(not exactly a test, just demonstrating the flow):
package org.activiti.designer.test.comp;

import static org.junit.Assert.assertNotNull;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.test.ActivitiRule;
import org.activiti.engine.test.Deployment;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:activitiTestContext.xml")
public class ProcessParallel extends AbstractTest
{
Logger logger = Logger.getLogger(ProcessParallel.class);
@Autowired
private RuntimeService runtimeService;
@Autowired
private RepositoryService repositoryService;

@Autowired
@Rule
public ActivitiRule activitiRule;

@Test
@Deployment(resources = { "diagrams/Parallel.bpmn" })
public void startProcess() throws Exception
{
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery()
    .deploymentName(this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName())
    .orderByDeploymenTime().asc().list().get(0);
  ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
  Assert.assertNotNull(processDefinition);
  logger.info("Actual Execution Order:");
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("parallelCompensationProcess");
  assertNotNull(processInstance);
  System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
}
}

Spring configuration file(activitiTestContext.xml):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<bean id="dataSource"
  class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
  <property name="driverClass" value="org.h2.Driver" />
  <property name="url"
   value="jdbc:h2:tcp://localhost/activiti;DB_CLOSE_DELAY=1000" />
  <!– <property name="url" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"
   /> –>
  <property name="username" value="sa" />
  <property name="password" value="" />
</bean>

<bean id="transactionManager"
  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
</bean>

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="dataSource" ref="dataSource" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="databaseSchemaUpdate" value="true" />
  <property name="jobExecutorActivate" value="true" />
  <property name="history" value="full" />
  <property name="customPostDeployers">
   <list>
    <bean class="org.activiti.engine.impl.rules.RulesDeployer" />
   </list>
  </property>
</bean>

<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
  <property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>

<bean id="activitiRule" class="org.activiti.engine.test.ActivitiRule">
  <property name="processEngine" ref="processEngine" />
</bean>

<bean id="historyService" factory-bean="processEngine"
  factory-method="getHistoryService" />
<bean id="formService" factory-bean="processEngine"
  factory-method="getFormService" />
<bean id="identityService" factory-bean="processEngine"
  factory-method="getIdentityService" />
<bean id="managementService" factory-bean="processEngine"
  factory-method="getManagementService" />
<bean id="repositoryService" factory-bean="processEngine"
  factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine"
  factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine"
  factory-method="getTaskService" />
</beans>

It gives:
1832 [main] INFO  org.activiti.designer.test.comp.ProcessParallel  - Actual Execution Order:
Script Task1
Compensation Script Task1
Script Task2
Script Task3
Script Task4
Compensation Script Task4
Compensation Script Task3
Compensation Script Task2

But I do not expect Compensation Script Task3 and Compensation Script Task2 to come after Compensation Script Task4. They should be called before that.

gokceng1
Champ in-the-making
Champ in-the-making
Were you able to look at test projects?

jbarrez
Star Contributor
Star Contributor
Yeah, it is indeed a bug: http://jira.codehaus.org/browse/ACT-1513