An order, from tap to kitchen
The customer’s app sends the order with its own id. The order service secures the payment and writes the order, as “placed”, with an outbox row in the same transaction; a relay publishes the event, and the kitchen service rings the tablet until someone accepts.
Acceptance is when the customer sees “confirmed”. Every later step is the same kind of conditional write, announced on the event stream.
- The customer places the order with its own id.
- The payment is secured and the order written, with an outbox row.
- The kitchen’s tablet rings until accepted.
- The customer hears “confirmed”.
Diagram as text
Components: Customer app (Client); API gateway (API gateway); Order service (Service); Payments (External API); Restaurant tablet (Client); Orders and outbox (SQL DB); Order events (Queue); Kitchen service (Service). Connections: Customer app → API gateway (order + its own id); API gateway → Order service; Order service → Payments (secure the amount); Order service → Orders and outbox (order + outbox, one write); Orders and outbox → Order events (relay), asynchronous; Order events → Kitchen service (new order), asynchronous; Kitchen service → Restaurant tablet (ring until accepted).
Read:Learn: Consistency trade-offsLearn: Event-driven / saga
Check yourself
The order service crashes just after writing the order. Does the kitchen still hear about it?
Show answerHide answer
Yes: the outbox row was written in the same transaction, so the relay publishes the event when it next runs.