liveBook · Manning

Exactly-once delivery

As explained in Kafka Streams in Action, Second Edition

Exactly-once semantics is a message-processing guarantee that each input record's effects are applied once without duplicate results despite retries or failures.

Exactly-once delivery ensures that records are neither lost nor delivered more than once, even when retries or failures occur. Kafka uses transactions to provide this guarantee. section 4.2.2

Choose the Kafka mechanism according to the scope of the guarantee:

  • Use an idempotent producer to deliver records in order and only once to a topic partition. section 4.4
  • Use a transactional producer to publish to multiple topics atomically: all messages succeed together or none do. section 4.4
  • Configure consumers with isolation.level=read_committed so they consume only committed records from transactional topics. section 4.7

Retry and transaction failure

A producer may resend a batch when an acknowledgment does not arrive, although the broker already appended it. With transactions, an aborted transaction is ignored by read_committed consumers; the consumer position advances while aborted data remains invisible. section 4.2.2 section 4.2.2

Enable transactional producers with a unique transactional.id for each producer. Treat exactly-once delivery as distinct from at-least-once processing, where retries or restart after an uncommitted offset can reprocess records. section 4.7 section 4.3.5

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Distinguishes delivery guarantees and explains idempotent, transactional, offset, and isolation configurations without showing transaction implementation code.
Examples
Uses producer retries, aborted transactions, per-partition idempotence, and atomic publication across multiple topics as concrete cases.
What it assumes
Assumes familiarity with Kafka producers, consumers, topics, partitions, acknowledgments, and committed offsets.
What you can do after
Configure KafkaProducer transactions, assign unique transactional IDs, and consume transactional topics using read_committed isolation.
How it connects
Connects Kafka transactions with idempotent producers, topic partitions, consumer offsets, and read_committed isolation.

Also explained in

Compare how 6 books explain exactly-once delivery →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.