A completion event for the multi-instance node that only executes when the completion conditions met

In Camunda 8, when an execution listener is set on a multi-instance node, the listener event is triggered every time a sub-task completes. We want to configure a completion event for the multi-instance node that only executes when the completion conditions of the entire multi-instance node are met, rather than being triggered after each sub-task completion. How should this functionality be implemented?

Hi @jamesxql,

In Camunda 8:

  • If you attach an execution listener (e.g., on end) to a multi-instance task, it triggers per inner instance.
  • That is expected behavior because, internally, Camunda models multi-instance as “looped” executions — one per instance.

Thus, a listener on end fires each time an inner execution finishes — not when the entire multi-instance finishes.

Option 1: To achieve what you want (trigger action once, when the entire multi-instance is complete) Use an Output Mapping after the multi-instance.

Instead of an execution listener, you can use an Output Mapping on the multi-instance activity, which triggers once, when the overall multi-instance node completes.

You can set a variable, and after that, in a Service Task or other mechanism, react based on that variable.

Option 2: Otherwise, wrap the multi instance task inside the sub-process and attach the execution listener to the sub-process which will invoke once.

Option 3: Use multi-instance variables to identify the last iteration and control the execution inside the execution listener.

numberOfInstances: The number of instances created.
numberOfActiveInstances: The number of instances currently active.
numberOfCompletedInstances: The number of instances already completed.
numberOfTerminatedInstances: The number of instances already terminated.
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.