Search code examples
workflowactivitibpmncamunda

Designing concurrent process start and correlations with Camunda


I am planning a simple workflow (shown in blue on the right) which should receive shipments belonging to the same order and continue the flow once all shipments have been collected.

enter image description here

Receiving shipments happen via REST and I plan to correlate to the right workflow instance using the order_id which is part of the request. The REST service is running in a cluster, so no in-VM locking is possible at this point.

I see two serious issues with this design:

  • concurrent inbound shipment requests will fail to correlate so they will start multiple workflow instances in the same time

  • even if the flow is started once successfully, Camunda will throw concurrent modification exception when simultanous shipment requests try to update the same workflow instance’s variables

How can I design this scenario to avoid these problems?


Solution

  • What about handling the shipments in a subprocess and notify the main process once everything is shipped. Something like this:

    enter image description here

    Edit: Updated diagram based on comments.