title: Designing concurrent process start and correlations with Camunda
body: <p>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.</p>
  
  <p><a href="https://i.stack.imgur.com/ysyqD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ysyqD.jpg" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>I see two serious issues with this design:</p>
  
  <ul>
  <li><p>concurrent inbound shipment requests will fail to correlate so they will start multiple workflow instances in the same time</p></li>
  <li><p>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</p></li>
  </ul>
  
  <p>How can I design this scenario to avoid these problems?</p>