0031. Consume OrderAllocated / OrderPartiallyAllocated by choreography
Status
Accepted. Records the order-management → work-planning integration that replaced a synchronous call; implemented before this record was written.
Context
order-management used to call POST /paths/{pathId}/work-units
synchronously to release work — a runtime coupling this service's owners
rejected once order-management became its own bounded context, in favour of the
event choreography already used with inventory-storage and
workforce-management. order-management now publishes OrderAllocated and
OrderPartiallyAllocated on warehouse.order-management.events; each carries
order_id, promise_date and a lines array (line_no, sku, path_id,
gift_wrap).
Decision
- Both event types are consumed identically by the
Consumer(handleOrderManagementEvent) and handed to theApplyOrderAllocateduse case. - One
WorkUnitper line, with a deterministic id"{order_id}-line-{line_no}", the order id asreference, the promise date as CPT, and the line'ssku/gift_wrapcarried through. The existingEnqueueWorkUnituse case is reused per line — no second admission path. - Idempotent at two levels. The CloudEvents
idis recorded in the processed-event table in the same transaction as every enqueue (ADR-0028), so a redelivery is a no-op and a failure rolls the mark back for retry. Separately,release.ErrDuplicateEntryfor a deterministic id (a later partial-allocation event for the same line, or an operator replay under a new event id) is a benign skip, never a reason to stall the partition. - Path validation lives in the use case.
ApplyOrderAllocatedvalidates every line'spath_idagainstports.PathCataloguebefore enqueueing anything (ADR-0012, ADR-0030); an unrecognized path fails the whole message, which is retried and then dead-lettered (ADR-0023). - Fire-and-forget. No reply event is published back to order-management.
The other direction of the relationship is separate: order-management
consumes this service's
PathCapacityChanged(ADR-0018).
Consequences
- No synchronous coupling: order-management and this service deploy and fail independently.
- order-management cannot learn from a reply whether a line was accepted; a rejected message surfaces only on this side (DLQ + ERROR log).
- The deterministic id makes
GET /work-units?reference=<order_id>the natural lookup for "what did this service do for order X". - Changing the id scheme, or adding a reply, is a cross-service contract change.