liveBook · Manning

Exactly-once delivery

As explained in Kafka for Architects

Exactly-once delivery is a processing guarantee in which each record's effect is applied once despite retries or failures.

An order-processing service might turn one order into shipment, billing, and inventory events. A retry after failure must not create a second set, while a skipped order would leave downstream systems incomplete. Exactly-once processing addresses this risk for Kafka read-process-write pipelines. section 7.4.2

The guarantee has a boundary. Kafka does not provide exactly-once delivery by default: retries can produce duplicates, so consumers must be designed with idempotence in mind. Kafka transactions instead make processing an input and publishing its Kafka outputs an atomic operation, including writes to multiple topics. section 10.1.3 section 7.6

Figure 7.24 OrderService reads, processes, and writes each event atomically.
A white rectangle with black text

AI-generated content may be incorrect.

The order pipeline shows why the shipment, billing, and inventory outputs need to succeed together rather than appear as partial results. section 7.4.2

In Kafka Streams, an all-or-nothing transaction coordinates:

  • Producing records to output topics. section 8.3.4
  • Updating state backed by changelog topics. section 8.3.4
  • Committing consumed-record offsets. Set processing.guarantee to EXACTLY_ONCE_V2 to enable this processing guarantee. section 8.3.4

Choose the guarantee for the effects that actually need it, rather than treating it as a blanket promise for every downstream system. Kafka does not currently support two-phase commit; the transactional outbox pattern is often used as a workaround. Kafka Streams provides exactly-once processing without custom deduplication logic for its supported pipeline. section 7.6 section 8.1.3

How Kafka for Architects covers it

How deep it goes
Details atomic output, state, and offset commits and names the Kafka Streams setting, without a full client implementation walkthrough.
Examples
Illustrates one order generating shipment, billing, and inventory events, where duplicates or omissions cause downstream discrepancies.
What you can do after
Operate/configure it in Kafka Streams with processing.guarantee set to EXACTLY_ONCE_V2.
How it connects
Links Kafka transactions, consumer offsets, state stores, changelog topics, and the transactional outbox pattern.

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 for Architects. The section links point to the parts of the book it draws on.