diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/ProducerConfig.java b/clients/src/main/java/org/apache/kafka/clients/producer/ProducerConfig.java
index 5d57da8fd8d..8b360d4d839 100644
--- a/clients/src/main/java/org/apache/kafka/clients/producer/ProducerConfig.java
+++ b/clients/src/main/java/org/apache/kafka/clients/producer/ProducerConfig.java
@@ -255,6 +255,7 @@ public class ProducerConfig extends AbstractConfig {
public static final String METRIC_REPORTER_CLASSES_CONFIG = CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG;
// max.in.flight.requests.per.connection should be less than or equal to 5 when idempotence producer enabled to ensure message ordering
+ // The value 5 is aligned with ProducerStateEntry#NUM_BATCHES_TO_RETAIN.
private static final int MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION_FOR_IDEMPOTENCE = 5;
/** max.in.flight.requests.per.connection
*/
@@ -263,8 +264,8 @@ public class ProducerConfig extends AbstractConfig {
+ " Note that if this configuration is set to be greater than 1 and enable.idempotence
is set to false, there is a risk of"
+ " message reordering after a failed send due to retries (i.e., if retries are enabled); "
+ " if retries are disabled or if enable.idempotence
is set to true, ordering will be preserved."
- + " Additionally, enabling idempotence requires the value of this configuration to be less than or equal to " + MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION_FOR_IDEMPOTENCE + "."
- + " If conflicting configurations are set and idempotence is not explicitly enabled, idempotence is disabled. ";
+ + " Additionally, enabling idempotence requires the value of this configuration to be less than or equal to " + MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION_FOR_IDEMPOTENCE + ","
+ + " because broker only retains at most 5 batches for each producer. If the value is more than 5, previous batches may be removed on broker side.";
/** retries
*/
public static final String RETRIES_CONFIG = CommonClientConfigs.RETRIES_CONFIG;