Task Marker — Multi-instance
In this part of Task marker we gonna talk about muti-instance.
muti-instance can be Sequencial or Parallel:
Sequential example:
A 5 developpers wanna candidate to a job, the candidature are accepted and all of them gonna pass the interview with the RH, each of them will request a salary and will pass the interview one by one (sequencialy).
in this cas we gonna create a bpmn diagram which contain a userTask that will be instantied multiple times (5 times in our example foreach Developper which gonna pass the interview) so its quiest sample.
let s do the modelisation:

the first task will call a java class in which we gonna create a two variables :
the first one “numbersOfCandidatures” is for the number of instance to create (numbers of developper to candidate)
the second one “salaryByDevelopper” is the salary requested by the developper in interview.

the task “interviw the developpers will be instancieted 5 times”( foreach developper will pass the interview)

The task here is marked as sequencial:

let s run the project and test:
after started the process, we can see the task “interview the developpers is executed:
This is the first instance for the first developper interview , so we can see his first request salary which equal to 54000, we can see anothers parameters like nbOfInstances =5 , nrOfCompletedInstances=0, nrOfActiveInstances=1

after completing this we gonna pass to the next instance related to the next developper which request 55000, and as we can see the nrOfCompletedInstances variable is incremented by 1

The third request a 60000 salary,and as we can see the nrOfCompletedInstances variable is incremented by 1 and loop counter is 2 also

the forth:

and the last:

so we had 5 instances for the same task as we saw.
the instance was created sequencialy
after completing the 5 instances of usertask we gonna pass to the next task

Parallel example:
Now we gonna try the parallel, and suppose that all the developpers will pass the interview in the same time in the same place,
we kept the same parameters and the same diagram, we switched only the task markel from sequential to parallel


let s execute:
Here we got 5 instances in the same time:



Github repo: https://github.com/ghailen/camunda-muti-instance-task
Thank you for reading my article, please contact me for any further informations.
Other Camunda topics:
camunda task events notifier camunda genericuser task listener in camunda task marker multi-instance taskmarker loop in camunda feel language camunda how to work with dmn how to work with dmn how-to-use-embedded-task-form-in-camunda all-about-camunda-database error-handling-in-camunda sub-process-in-camunda gateways-in-camunda camunda-with-spring-boot-example task-in-camunda events-in-camunda





