Outbox Pattern
Problem
Your service does:
1. Save Order
2. Publish OrderCreated
The database save succeeds.
Then the process crashes before publishing.
Now the order exists but nobody receives the event.
Solution — Transactional Outbox
Save the business change and outgoing event record in the same database transaction.
Transaction:
Order
+
Outbox event
↓ later
Publisher → Broker
Core idea: the outbox pattern closes the consistency gap between database changes and message publication.