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

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.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?