Opening Scenario

Your orders-service owns a Postgres orders table. When a customer places an order, the service does two things in its request handler: INSERT INTO orders ... and kafkaProducer.send("order-placed", event). The bug ticket reads: "We charged a customer twice and shipped nothing." Investigation finds three production incidents in two weeks: an order row was committed but the Kafka send timed out (no event, downstream services didn't react); an order row failed to commit but the Kafka send succeeded (event published, no row, downstream charged a phantom order); a Kafka send succeeded but the response was lost on the network so the service retried, double-publishing. The team lead writes "USE OUTBOX" on the postmortem in red. Before nodding, you need to understand what outbox actually fixes, what it costs, and what alternatives lose against it.


Question Progression

1. What's the actual problem with "DB write + Kafka send"?

Question. Why isn't INSERT followed by producer.send a correct way to publish an…

In the full tutorial

  • When to Reach for This

Glossary history

Click dotted jargon to save explanations here.