Transactional outbox
Write the event as an outbox row in the same transaction as the state change, then let a relay publish committed rows and mark them sent. Events are never lost or invented; a crash can publish one twice, so consumers dedupe.
Minimal example
SELECT id, topic, key_, payload FROM outbox
WHERE sent_at IS NULL ORDER BY id LIMIT 100
FOR UPDATE SKIP LOCKED;Learn this concept
Lesson 3.14 · Transactional outbox writesUsed in exercises
Exercise 3.15 · Outbox relay to order-events Exercise 3.19 · API and notifier shutdown Exercise 3.23 · Concurrent outbox relay Exercise 8.11 · Two-minute project demo package Exercise 8.12 · Engineering walkthrough packageRelatedAt-least-once delivery