AnsweredAssumed Answered

Why ParallelMultiInstanceBehavior.leave() take all OutgoingTransitions ?

Question asked by johnfan on Aug 4, 2016
Latest reply on Dec 14, 2017 by bisgoon
I'm using Activiti 5.21.0 as BPM engine.

Asked to keep everything simple, i removed gateways(I know it is not good). Now the workflow is simpler. like
[img]https://camo.githubusercontent.com/458b61e9114bec5ee84e33d827e8f6f031f60e2a/687474703a2f2f7777772e6368616e6a61722e6d652f61637469766974692f676174657761792d6e6f6e652e706e67[/img]

I set conditionExpression for every sequenceFlow, looking forward only one of userTask 2&3 would be activated depend on the exclusive condition set on the flows. It works fine only when userTask1 is not ParallelMultiInstanceTask. But if i set userTask1 parallel, when complete userTask1, no condition is calculated. userTask2 and userTask3 are both activated.

After looked through codes, i found that ParallelMultiInstanceBehavior.leave() act differently against other Behaviors.

if (joinedExecutions.size() >= nrOfInstances || completionConditionSatisfied(execution)) {
 
  // Removing all active child executions (ie because completionCondition is true)
  List<ExecutionEntity> executionsToRemove = new ArrayList<ExecutionEntity>();
  for (ActivityExecution childExecution : executionEntity.getParent().getExecutions()) {
    if (childExecution.isActive()) {
      executionsToRemove.add((ExecutionEntity) childExecution);
    }
  }
  for (ExecutionEntity executionToRemove : executionsToRemove) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Execution {} still active, but multi-instance is completed. Removing this execution.", executionToRemove);
    }
    executionToRemove.inactivate();
    executionToRemove.deleteCascade("multi-instance completed");
  }
  executionEntity.takeAll(executionEntity.getActivity().getOutgoingTransitions(), joinedExecutions);
}


I wonder if there are some reason when leaving ParallelMultiInstance, every outgoing should be taken. Is it possible to filter OutgoingTransitions using conditions?

Greetings.

Outcomes