The producer stamps a sequence number so the broker can discard a retried duplicate. Default since 3.0.
props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
// implies acks=all, retries>0, max.in.flight.requests.per.connection<=5
Without idempotence: a timeout followed by a successful retry
writes the record twice.
With it: the broker sees the same producer id and sequence, and drops the second.
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11