liveBook · Manning

At-least-once delivery

As explained in Kafka Streams in Action, Second Edition

At-least-once delivery is a processing guarantee that prevents loss of records but permits a record to be processed more than once.

At-least-once delivery guarantees that records are not lost, while allowing a record to be delivered or processed more than once. Kafka provides this guarantee by default. section 4.2.2 section 4.7

Duplicates arise when successful processing is not followed by a durable acknowledgment:

  • A producer may resend a batch when the broker appends it but the acknowledgment does not arrive in time. section 4.2.2
  • A consumer may process records and fail before committing offsets, then restart from the last committed offset and process them again. section 4.3.5
  • Processing records synchronously before committing helps preserve the guarantee; asynchronous handoff can commit offsets before processing finishes and lose records. section 4.3.5

Commit after processing

A consumer polls a batch, passes it to recordProcessor.processRecords, retrieves the resulting offsets, and calls consumer.commitSync(offsetsAndMetadata). If the application fails before the commit, the batch is read again; processing therefore needs to tolerate duplicates. section 4.3.5

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains producer and consumer failure paths, commit timing, and Java implementation, but stops short of duplicate-handling strategies.
Examples
Uses producer acknowledgment timeouts, consumer restarts, committed offsets, and process-then-commit Java code.
What it assumes
Assumes basic Kafka producer, consumer, topic, partition, poll, and offset concepts.
What you can do after
Diagnose/debug with it by identifying duplicate processing after failed commits and unsafe commits during asynchronous work.
How it connects
Connects Kafka, consumer offsets, retries, at-most-once delivery, exactly-once delivery, and idempotent producers.

Also explained in

Compare how 4 books explain at-least-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.