Concurrency Concerns
Essential knowledge
Changed on:
17 Apr 2025
Overview
This articles illustrated different case scenarios where concurrency can happen when updating fulfilment attributes, and how it can be addressed.Key points
- Concurrency happens when 2 processes update the same attribute at the same time
- Concurrency can result in data loss
- Concurrency can be solved by event queue management or code changes
Purchase Orders (POs)
Concern with updating fulfilment attributes (PO is one large single json attribute) - 2 processes updating the same attribute at the same time can result is data loss 3 examples where concurrency can be an issue:- "deliveredQuantity" in UpdateDeliveredQtyForPOInvoice.java
- "invoicedQuantity" in UpdateInvoicedQtyForPOInvoice.java
- "InvoicedQty" in UpdateInvoicedQtyAttribute.java
Order Item Line Number
GenerateOrderItemLineNumber - possible concurrency issue generating order line numbersPossible Solutions
- See if there is any scope to break data mapping down to individual attributes in some key places (instead of grouped JSON attributes) to avoid such scenarios
- Reduce number of events that could cause a clash - e.g. remove PO confirmation and rely on invoice only?
- Manage message queue order (e.g. using queue ID) to send messages to one at a time Fluent in correct order, but Fluent would need to respond each time
- Manage consolidation of multiple events to same PO externally to Fluent, to send in a single update at a time - have an external service and queue that only updates the Fluent PO attribute once