Inbox and Outbox - Junior¶
Writing a business row and publishing Kafka separately creates a dual-write gap.
sequenceDiagram
participant A as App
participant D as Database
participant K as Kafka
A->>D: commit order
Note over A: crash
A-xK: event never published
Reversing the order can publish an event for a transaction that later fails. Local atomic storage plus retryable delivery is safer than trying to time two systems perfectly. Test yourself¶
- What is the dual-write gap?
- Why is publish-first also unsafe?
- Why must consumers expect duplicates? Continue to
middle.md.