Save, Then Publish, Is Two Writes: The Transactional Outbox Pattern
Both of my CQRS posts contain the same bug: the command handler commits to the database and then publishes an event, and nothing makes those two writes agree. Why reordering and retries don't fix it, how the transactional outbox does, what it costs in latency, load, duplicates and ordering, and when you don't need it at all.