Lazily process batch from external system


I’m trying to model a business process which I’ve simplified as follows:

  1. 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.
  2. If more items arrive for an existing batch, they should be added to the existing batch.
  3. We must wait until the entire batch is processed before continuing.
  4. 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.

Hey @jmcmaha1,

Maybe an event subprocess could solve your problem? For one batch you would have one instance and missing items could be received with a non interrupting start message inside the event subprocess. I attached an example of what I mean and hope it helps you.

In general it is not best practice to send a messages and catch that same message within the same process.

I hope that helps Cheers
Neleexample.bpmn (12.1 KB)


Brilliant! That did the trick and is much cleaner than my solution. Thanks a ton!