@@ -126,6 +126,7 @@ static final class ConsoleProducerOptions extends CommandDefaultOptions {
126126 private final OptionSpec <Long > metadataExpiryMsOpt ;
127127 private final OptionSpec <Long > maxBlockMsOpt ;
128128 private final OptionSpec <Long > maxMemoryBytesOpt ;
129+ @ Deprecated (since = "4.2" , forRemoval = true )
129130 private final OptionSpec <Integer > maxPartitionMemoryBytesOpt ;
130131 private final OptionSpec <String > messageReaderOpt ;
131132 private final OptionSpec <Integer > socketBufferSizeOpt ;
@@ -156,8 +157,11 @@ public ConsoleProducerOptions(String[] args) {
156157 .withOptionalArg ()
157158 .describedAs ("compression-codec" )
158159 .ofType (String .class );
159- batchSizeOpt = parser .accepts ("batch-size" , "Number of messages to send in a single batch if they are not being sent synchronously. " +
160- "please note that this option will be replaced if max-partition-memory-bytes is also set" )
160+ batchSizeOpt = parser .accepts ("batch-size" , "The buffer size in bytes allocated for a partition. " +
161+ "When records are received which are smaller than this size the producer " +
162+ "will attempt to optimistically group them together until this size is reached. " +
163+ "This is the option to control batch.size in producer configs. " +
164+ "Please note that this option will be replaced if max-partition-memory-bytes is also set." )
161165 .withRequiredArg ()
162166 .describedAs ("size" )
163167 .ofType (Integer .class )
@@ -212,9 +216,11 @@ public ConsoleProducerOptions(String[] args) {
212216 .ofType (Long .class )
213217 .defaultsTo (32 * 1024 * 1024L );
214218 maxPartitionMemoryBytesOpt = parser .accepts ("max-partition-memory-bytes" ,
215- "The buffer size allocated for a partition. When records are received which are smaller than this size the producer " +
219+ "(Deprecated) The buffer size in bytes allocated for a partition. " +
220+ "When records are received which are smaller than this size the producer " +
216221 "will attempt to optimistically group them together until this size is reached. " +
217- "This is the option to control `batch.size` in producer configs." )
222+ "This is the option to control batch.size in producer configs. " +
223+ "This option will be removed in Apache Kafka 5.0. Use --batch-size instead." )
218224 .withRequiredArg ()
219225 .describedAs ("memory in bytes per partition" )
220226 .ofType (Integer .class )
@@ -335,6 +341,10 @@ void checkArgs() {
335341 readerPropertyOpt = propertyOpt ;
336342 }
337343
344+ if (options .has (maxPartitionMemoryBytesOpt )) {
345+ System .out .println ("Warning: --max-partition-memory-bytes is deprecated and will be removed in Apache Kafka 5.0. Use --batch-size instead." );
346+ }
347+
338348 try {
339349 ToolsUtils .validateBootstrapServer (options .valueOf (bootstrapServerOpt ));
340350 } catch (IllegalArgumentException e ) {
@@ -398,7 +408,6 @@ Properties producerProps() throws IOException {
398408 CommandLineUtils .maybeMergeOptions (props , RETRY_BACKOFF_MS_CONFIG , options , retryBackoffMsOpt );
399409 CommandLineUtils .maybeMergeOptions (props , SEND_BUFFER_CONFIG , options , socketBufferSizeOpt );
400410 CommandLineUtils .maybeMergeOptions (props , BUFFER_MEMORY_CONFIG , options , maxMemoryBytesOpt );
401- // We currently have 2 options to set the batch.size value. We'll deprecate/remove one of them in KIP-717.
402411 CommandLineUtils .maybeMergeOptions (props , BATCH_SIZE_CONFIG , options , batchSizeOpt );
403412 CommandLineUtils .maybeMergeOptions (props , BATCH_SIZE_CONFIG , options , maxPartitionMemoryBytesOpt );
404413 CommandLineUtils .maybeMergeOptions (props , METADATA_MAX_AGE_CONFIG , options , metadataExpiryMsOpt );
0 commit comments