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?
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 exclusiveGateway
s . Check this links for additional information:
MultiInstanceActivityBehavior.java - int resolveNrOfInstances(ActivityExecution execution) ParallelMultiInstanceBehavior - void createInstances(ActivityExecution execution); SequentialMultiInstanceBehavior - void createInstances(ActivityExecution execution);