What is the Transactional Outbox pattern?
Answer
The Transactional Outbox pattern solves the dual-write problem: how to atomically update a database AND publish an event to a message broker. If you write to the database and then publish to Kafka, the two are not atomic — a crash between them leaves you with either missing events or orphaned events. The solution: write the event to an outbox table in the same local database transaction as the business data update. A separate Message Relay process (e.g., using Debezium CDC — Change Data Capture) reads from the outbox table and publishes the events to the broker. This guarantees exactly-once semantics at the database level, even if the service crashes, because the event is committed atomically with the business data.
Previous
What is the API composition pattern?
Next
Why is two-phase commit (2PC) problematic in microservices?
More Microservices Architecture Questions
View all →- Intermediate What is event-driven architecture and how does it apply to microservices?
- Intermediate What is the Saga pattern in microservices?
- Intermediate What is CQRS (Command Query Responsibility Segregation)?
- Intermediate What is event sourcing in microservices?
- Intermediate What is the Circuit Breaker pattern?