Hi Team,
We have a use case in our application where we need to process a customer order which is having multiple order items. for each order item, we need to execute a set of tasks in addition to some common tasks on the order level. to achieve this, we have designed the two bpmns. one is the parent which will perform order level tasks and the child bpmn will perform tasks related to each order item. depending on the no of order items in the order, we are creating that many parallel instances of child bpmn and passing the common parent business key to all child instances to keep the parent-
child relation ship.
To achieve the parallel multi instance behavior’s without any race conditions, we are using the multi-instance-with-delegate pattern described in this git hub project - https://github.com/camunda-consulting/camunda-7-code-examples/tree/master/snippets/multi-instance-with-delegate
Now the problem is, after all the child instances are completed, we have some tasks left to perform on the parent instance. event though the parent instances is having a timer which periodically checks the child instance completion, we feel this solution will not fit if the child instances are long running. as the timer will poll indefinitely and will put more load on the job executor and to the database. to solve this problem, we have added a receive task on parent instance, which all child instances will try to signal upon their completion. but this can lead to another race condition when more than one child instances trying to correlate the message on parent.
Is there any other approach to solve this problem? please share your valuable inputs. attaching my bpmns for more clarity.
MiParent.bpmn (14.3 KB)
MiChild.bpmn (6.9 KB)