A lost reply, a safe retry
Sequence between a caller, an order service, its ledger with an outbox table, and an ERP.
Read the full description
One: the caller posts an order with request key K. Two: the service writes the order and its outbound message in one database transaction. Three: the 201 Created reply is lost in transit. Four: the caller times out and retries with the same key. Five: the service finds key K and creates no second order. Six: it returns the original result. Seven: a relay delivers the outbound message to the ERP at least once. Eight: the ERP acknowledgement closes the outbox row. The oldest open row is the figure an operator watches.
Order with key K
One: the caller posts an order with request key K.
Order and outbox
Two: the service writes the order and its outbound message in one database transaction.
Outgoing
Lost response
Three: the 201 Created reply is lost in transit.
Use the same key
Four: the caller times out and retries with the same key.
Find the committed order
Five: the service finds key K and creates no second order.
Incoming
Original response
Six: it returns the original result.
At-least-once delivery
Seven: a relay delivers the outbound message to the ERP at least once.
Outgoing
ERP acknowledgement
Eight: the ERP acknowledgement closes the outbox row.
Oldest outstanding event
The oldest open row is the figure an operator watches.