Skip to content
Kafka Is FunProgress

ScenarioProduction Scenarios

How do you implement exactly-once delivery in a Kafka-to-database pipeline?

Reference answer

The core challenge: write to Kafka AND database atomically. Options: 1) Outbox Pattern: write to DB first in same transaction as your business data, then CDC (Debezium) publishes to Kafka — database is source of truth, no dual-write risk. 2) Idempotent consumer: use acks=all + enable.idempotence=true on producer; consumer upserts to DB using the Kafka offset as the primary key (upsert by offset+partition). 3) Kafka Transactions: consume from Kafka, write to DB, commit both in a ChainedKafkaTransactionManager — but this requires DB transaction interop with Kafka transactions. The Outbox Pattern is most practical and production-proven.

Expected key concepts: Outbox Pattern, Debezium, CDC, source of truth, dual-write, idempotent consumer, upsert, offset as primary key, ChainedKafkaTransactionManager, DB transaction, Kafka Transactions, production-proven