cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel gateway does not activate

mahavirj
Champ in-the-making
Champ in-the-making
Since <inclusiveGateway> is not supported as yet, a combination of divergent parallelGateway + exclusiveGateway has to be used to get that functionality. In one specific scenario, however, a convergent parallelGateway does not activate. I could reproduce this issue by adding this scenario to the SubProcessTest.fixSystemFailureProcess.bpmn20.xml that comes with the examples in activiti R5.2.  Does this scenario violate BPMN2, or is this a bug?

See the process flow below. The sequence between the "Begin/End POC Sequence" comments is the scenario added for this test. "subProcessJoin" does not activate (all intermediate tasks were completed)

    <subProcess id="subProcess">
   
      <startEvent id="subProcessStart" />
      <sequenceFlow id="flow2" sourceRef="subProcessStart" targetRef="subProcessFork" />
     
      <parallelGateway id="subProcessFork" />
      <sequenceFlow id="flow3" sourceRef="subProcessFork" targetRef="task1" />
      <sequenceFlow id="flow4" sourceRef="subProcessFork" targetRef="task2" />
     
      <userTask id="task1" name="Investigate hardware" activiti:assignee="kermit" />
      <sequenceFlow id="flow5" sourceRef="task1" targetRef="subProcessJoin" />
     
      <userTask id="task2" name="Investigate software" activiti:assignee="kermit" />
      <sequenceFlow id="flow6" sourceRef="task2" targetRef="subProcessJoin" />
     
      <!– Begin POC Sequence –>     
      <userTask id="poc_task3" name="Task Foo" activiti:assignee="kermit" />
      <userTask id="poc_task4" name="Task Moo" activiti:assignee="kermit" />
      <exclusiveGateway id="poc_eg1" />
      <exclusiveGateway id="poc_eg2" />
      <parallelGateway id="poc_pg1" />
                 
      <sequenceFlow id="sp3_flow29" name="" sourceRef="task2"  targetRef="poc_eg1" ></sequenceFlow>
      <sequenceFlow id="sp3_flow301" name="" sourceRef="poc_eg1" targetRef="poc_pg1" >
            <conditionExpression xsi:type="tFormalExpression"><![CDATA[${1 == 1}]]></conditionExpression>
      </sequenceFlow>     
      <sequenceFlow id="sp3_flow302" name="" sourceRef="poc_eg1" targetRef="subProcessJoin" >
            <conditionExpression xsi:type="tFormalExpression"><![CDATA[${1 == 2}]]></conditionExpression>
      </sequenceFlow>     
      <sequenceFlow id="sp3_flow303" name="" sourceRef="poc_pg1"  targetRef="poc_task3" ></sequenceFlow>
      <sequenceFlow id="sp3_flow304" name="" sourceRef="poc_pg1"  targetRef="poc_eg2" ></sequenceFlow>
      <sequenceFlow id="sp3_flow305" name="" sourceRef="poc_eg2" targetRef="poc_task4">
               <conditionExpression xsi:type="tFormalExpression"><![CDATA[${ 1 == 1 }]]></conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="sp3_flow306" name="" sourceRef="poc_eg2" targetRef="subProcessJoin">
               <conditionExpression xsi:type="tFormalExpression"><![CDATA[${ 1 == 2 }]]></conditionExpression>
      </sequenceFlow> 
      <sequenceFlow id="sp3_flow34" name="" sourceRef="poc_task3" targetRef="subProcessJoin"></sequenceFlow>
      <sequenceFlow id="sp3_flow35" name="" sourceRef="poc_task4" targetRef="subProcessJoin"></sequenceFlow>                  
     
      <!– End POC Sequence –>
     
      <parallelGateway id="subProcessJoin" />
      <sequenceFlow id="flow7" sourceRef="subProcessJoin" targetRef="subProcessEnd" />
      <endEvent id="subProcessEnd" />
   
    </subProcess>
7 REPLIES 7

jbarrez
Star Contributor
Star Contributor
I'm not quite following what you are trying to acomplish here. Could you provide a visual diagram to make it more clear?

mahavirj
Champ in-the-making
Champ in-the-making
Here's the subprocess flow. PG = parallel gateway, EG = exclusive gateway.  The issue is PG2 does not activate

[attachment=0]Update External Systems.jpg[/attachment]

jbarrez
Star Contributor
Star Contributor
The parallelGW will activate only if the number of incoming executions is equal to the number of incoming sequence flow.

In this case, you have 4 incoming sequence flow, but PG2 can maximum receive 3 executions in the best case (if I'm not mistaken).
So the parallel gateway will indeed never activate. Placing a converging exclusive gateway in between should do the trick, I think.

mahavirj
Champ in-the-making
Champ in-the-making
Yes, if I change PG2 to an exclusive gateway, say EGX, it works. However, according to BPMN2, a converging exclusive gateway does not synchronize flows, which means in this case it will always get triggered since task1 is always being completed regardless of what happens in EG2.  i.e. I don't want the subprocess to end just based on task1 completion.

So, if I leave task1->PG2 flow untouched and converge the other 4 flows to EGX and connect EGX to PG2 it works conditionally.

i.e. if EG1 evaluates to true EG1->EGX->PG2 does not work. But, if EG1 evaluates to false and EG2 evaluates to true, it works since the number of flows = number of executions @ PG2.

mahavirj
Champ in-the-making
Champ in-the-making
Got it to work by adding a some 'do nothing' servicetasks when there is no need for an execution instance for e.g. between eg1->egx->pg2.  This should not be necessary though. Would it not be possible to count the execution instance of task2 when applying that rule (#of flows=#of executions) for activating paralell gateway?

jbarrez
Star Contributor
Star Contributor
Could you attach your process xml, because it is hard to follow.

Would it not be possible to count the execution instance of task2 when applying that rule (#of flows=#of executions) for activating paralell gateway

I'm not following here, why would task2 have influence on the count of the parallel gateway?

mahavirj
Champ in-the-making
Champ in-the-making
In the diagram, there are 5 inflows to parallel gateway PG2.  Three of them have executions (task1, task4, task3) and two don't (EG1-to-PG2 and EG2-to-PG2).  Since the number of executions != number of flow,PG2 does not activate.

But, this is a valid requirement i.e. there is really nothing to do in EG1-to-PG2 and EG2-to-PG2.  Changing PG2 to an exclusive gateway will not help because completion of task1 will always activate it i.e. it wont wait for the result of the other 4 flows

So, the only way out is leave PG2 as a parallel gateway and define a do nothing <servicetask> for each of the EG1-to-PG2 and EG2-to-PG2 flows. This will make the number of executions == number of flows in all cases and will activate PG2 correctly.

However, these do-nothing <servicetask> are unnecessary. It should just be a matter of counting the # of executions…that's why i was suggesting to use task2 execution-id as the execution token for the flows which do not have an execution (in this case EG1-to-PG2 and EG2-to-PG2) i.e task2 is the preceding task for those do-nothing flows

The subprocess XML was in the first post. However, let me know if you still need the entire process xml and the unit tests