Duplicate start and resume after interruption

same IdempotencyKey converges on one OrderId — recovery replays the stream before choosing the next step

Duplicate start and resume after interruption same IdempotencyKey converges on one OrderId — recovery replays the stream before choosing the next step [par] StartOrderReq(same IdempotencyKey) [par] Reserve mapping [par] StartOrderReq(same IdempotencyKey) [par] Reserve mapping One OrderId Same OrderId StartOrderWorkflowReq StartOrderWorkflowReq Deduplicate SourceCommandId StartOrderWorkflowRes StartOrderWorkflowRes Replay OrderId stream InventoryReserved state AuthorizePaymentReq(existing PaymentId) Authorization result Append Payment event with expected version Client A · Sequence participant Client A Client B · Sequence participant Client B CommerceApi A · Sequence participant CommerceApi A CommerceApi B · Sequence participant CommerceApi B Commerce State · Sequence participant Commerce State OrderWorkflow · / Order Spot · Sequence participant OrderWorkflow / Order Spot Order Event Store · Sequence participant Order Event Store Payment · Sequence participant Payment

Concurrent start (mermaid par ... and ...)

  • • Messages 1-4 ([par]-tagged) run concurrently, not sequentially: Client A → CommerceApi A → Commerce State and Client B → CommerceApi B → Commerce State happen at the same time. Whichever request first succeeds at reserving the mapping decides the OrderId; the other discards its candidate and uses the same one.

Recovery replays the stream before choosing the next step

  • • mermaid Note over Workflow,Events (positioned right before 'Replay OrderId stream'): 'Recovery replays the stream before choosing the next step.'
  • • If SourceCommandId is already in the stream, the Workflow doesn't re-record the event — it returns the fold result. The Workflow replays to confirm the last-recorded state (e.g. InventoryReserved), skips the completed step, and runs from payment onward. This rule applies both to an explicit ContinueOrderWorkflowReq and to resumption after a planned relocation.