avatarGhailene ben Marzouk

Summary

The web content discusses the implementation of multi-instance tasks in Camunda BPMN workflows, differentiating between sequential and parallel execution.

Abstract

The article provides an in-depth look at multi-instance tasks within Camunda, a workflow and decision automation platform. It explains how these tasks can be configured to execute sequentially or in parallel, using a practical example of a job application process involving multiple developers. The sequential approach involves instantiating a user task multiple times, where each developer passes through an interview one after the other. In contrast, the parallel approach allows all interviews to occur simultaneously. The article includes Java class integration for dynamic instance creation and demonstrates the process with BPMN diagrams and runtime screenshots. It concludes with a link to a GitHub repository containing the example project and invites readers to contact the author for further information.

Opinions

  • The author suggests that multi-instance tasks are a powerful feature in Camunda for handling repetitive processes.
  • The article implies that the choice between sequential and parallel task execution should be based on the specific requirements of the workflow.
  • The use of BPMN diagrams and runtime screenshots indicates the author's preference for visual aids to clarify complex concepts.
  • By providing a GitHub repository, the author encourages hands-on learning and experimentation with the provided examples.
  • The invitation for further contact suggests the author's openness to engagement and support for the Camunda community.

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

Camunda
Tasks
Bpmn
Diagrams
Configuration
Recommended from ReadMedium