Question

In our workflows we have several multi-instance call activities, like the following:

<callActivity id="loopFoos" calledElement="${workflowResolver.resolveWorkflowName(foo)}">
    <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${foos}" activiti:elementVariable="foo" />
</callActivity>

The problem is that some of the collections are empty and that leads to exceptions because activiti assumes that there is at least one element in the collection. We could make decisions around all the subworkflow calls but that would pollute the the workflow diagram with non-business-relevant details.

What we would need is the behaviour of java for each like

for (Foo foo : foos) {
 // call workflow
}

where empty collections simply don't enter the loop.

Is there a way to make activiti behave like this? How would you model the workflow if there isn't?

Was it helpful?

Solution

There is no way to solve this problem using standard Activiti capabilities. So the only option is using gateways or Java Service Task with class implementing ActivityBehaviour (not recommended) to control sequence flow. I prefer using exclusiveGateways . Check this links for additional information:

  1. Discussion at Activiti official forum

  2. MultiInstanceActivityBehavior.java - int resolveNrOfInstances(ActivityExecution execution) ParallelMultiInstanceBehavior - void createInstances(ActivityExecution execution); SequentialMultiInstanceBehavior - void createInstances(ActivityExecution execution);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top