Search code examples
spring-bootcamundacamunda-modeler

Dynamic User Task Assignment depending on Product attributes in Camunda


Is there any best practice for running a Camunda process definition with multiple products (each product is assigned to a different team with minimum communication) without creating a new deployment of Camunda, just by managing one deployment of Camunda with many of java delegates for each product?


Solution

  • If I understand correctly, you want to use the same process definition to process different kinds of products. Depending on the characteristics of the product different teams or individuals should perform the steps in the process. So it is simply a question of work assignment. Camunda llows you to assign work to an individual (assignee), a group of individuals (candidate users) or to a list of user groups (candidate groups). See: https://docs.camunda.org/manual/latest/reference/bpmn20/tasks/user-task/#user-assignment-using-camunda-extensions

    This work assignmhttps://docs.camunda.org/manual/latest/reference/bpmn20/tasksThe value used for work assignment does not have to be static. You can use an expression referring to a process data, which can be computed and set a t runtime before the task is reached.

    Once way to formulate complex work assignment logic without writing code in a business friendly manner is DMN. Please see this example: https://emsbach.medium.com/camunda-bpm-user-task-assignment-based-on-a-dmn-decision-table-32116a019a00 The decision table contains work assignment rules based on the different product attributes. For different products with different attributes the decision table will lead to a different result (assignee, candidate user or candidate groups). The results are the used in the subsequent user task for dynamic work assignment.

    If the product requires different code to be executed in service tasks, then you can either

    • branch in the process and create different service tasks for different product
    • make the JavaDelegate implementation read the product data from the execution and adjust code branch / behavior depending on product attributes
    • use a dynamic delegate expression which refers to a different Spring Bean / Java delegate depending on the value of a product attribute (e.g. the product id)