Enabling an Idempotent Producer

Describes how to enable an idempotent producer. Idempotence refers to exactly-once message delivery semantics.

To enable idempotence, the enable.idempotence configuration must be set to true. When set, the retries configuration defaults to Integer.MAX_VALUE and the Acks configuration defaults to all.

The idempotence producer option is set by setting the enable.idempotence value of true passed through the ProducerConfig class.

Constant Field Values
Modifier and Type Constant Field Value
public static final java.lang.String ENABLE_IDEMPOTENCE_CONFIG enable.idempotence

Example Code Snippet:

props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
Note: The default is false, which retains at-least-once message delivery semantics.
Tip: There are no API changes for the Idempotent Producer functionality, so existing applications do not need to be modified except to enable the producer configuration property.