Practice this topic in a realistic system design interview
Suppose we have an order service in an e-commerce application. When a customer places an order, the service saves it to a database and publishes an OrderCreated event to a message broker like Kafka.
Other services depend on that event:
So the order service needs to perform two operations: write the order to its database and publish an event to the broker. The problem is that these are two separate systems. A normal database transaction cannot atomically commit changes to both. This is known as the dual-write problem.
The transactional outbox pattern is the standard way to solve it.
In this chapter, we will look at how the outbox pattern solves the dual-write problem, how events are reliably published to a message broker, and the important details around delivery guarantees, ordering, retries, and cleanup.