Getting events out reliably
The transactional outbox, Debezium change data capture, idempotent consumers and delivery guarantees.
Transactional outbox
An order and the event that announces it are two writes to two systems. The outbox turns them into one transaction in the database and lets the transaction log carry the event to Kafka.
Log tailing with Debezium
Reading a database's transaction log turns every committed change into an event without touching the application: slots, snapshots, replica identity, tombstones, heartbeats and the embedded engine.
Managing connector offsets
A source connector remembers its place in the database log. Stopping it, reading that place, moving it forward, resetting it and recovering a lost replication slot, with what PostgreSQL does to each.
Idempotent consumer and inbox
Kafka delivers an event at least once, and a decrement is not safe to repeat. The inbox records the event id in the same transaction as the effect, so a duplicate record and a redelivery after a crash change nothing.
Exactly-once with Kafka transactions
A service that reads a record, processes it and writes a result can crash between the write and the offset commit. A Kafka transaction holds the output records and the input offsets together, and a read_committed reader never sees half of it.
Retry and dead letter
A consumer meets three kinds of bad record: one that never parses, one that is never valid and one that fails only while a row is locked. Retry the third, dead-letter the first two, and keep their original bytes.