I have a multi-instance service task that runs 3 times. After completing 1 of the 3 instances, I was expecting the number of tokens to decrease to 2 but it still shows 3 blue tokens
However, when I check the history view, it shows only two blue tokens
Is this expected or am I missing something? I wanted to ask the reasoning behind this or if there is better way to see at runtime only the number of running instances without including the completed ones.
As you can see in the image, there is a variable created called “nrOfActiveInstances” that tells you how many instances of this multi-instance are still running.
Below is what each variable means:
loopCounter = counts how many loops the multi-instance has already executed.
nrOfActiveInstance = counts how many instances are still active in this multi-instance.
nrOfCompletedInstances = counts how many instances have already been completed by the multi-instance.
nrOfInstance = counts the number of total instances of this multi-instance.
This happens because an instance of a multi-instance does not create several sub-instances… but rather creates several “executions” of the same instance… so the token value that you see on the Camunda front page refers to the number of executions that will be performed for that instance…
This means that the number that you see on the front page refers to the “nrOfInstances” variable.
Multi-instance it’s basically like “running a for loop” on an array of instances.