I’m trying to model a business process which I’ve simplified as follows:
- An external system sends a list of “items” as part of a batch. This initial list may not contain all items in the batch, but we are able to find the total number of items to expect for a particular batch.
- If more items arrive for an existing batch, they should be added to the existing batch.
- We must wait until the entire batch is processed before continuing.
- A timeout must be specified for all items in a batch to be received and processed.
Here’s my (naïve) BPMN implementation:
The idea is that a process instance is “assigned” to a batch when items are first received for that batch. As more items arrive, we process the items and notify the original process instance.
This works in a perfect scenario. However, the “Item processed” task fails to keep up when multiple process instances are created (i.e. when multiple sets of items are received for the same batch at the same time). Also, it feels like there should be a better way of fulfilling these requirements.
I’ve also experimented with using a conditional event (updating a count variable as items are processed), but this still requires multiple process instances per batch and seems to be a race condition waiting to happen.
Any advice is greatly appreciated! We are using version 7.14.0 of Camunda.