acks=1 acknowledges once the leader has written, so a leader failure before replication loses the record.
props.put(ProducerConfig.ACKS_CONFIG, "all");
props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
props.put(ProducerConfig.RETRIES_CONFIG, Integer.MAX_VALUE);
// broker side:
// min.insync.replicas=2 on a 3-replica topic
acks=0 fire and forget - fastest, loses data on any failure
acks=1 leader only - loses data if the leader dies before replicating
acks=all leader + min.insync.replicas - survives one broker loss
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