jiafu1115 commented on code in PR #20832:
URL: https://github.com/apache/kafka/pull/20832#discussion_r2499312603


##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -1044,6 +1044,46 @@ public Future<RecordMetadata> send(ProducerRecord<K, V> 
record, Callback callbac
         return doSend(interceptedRecord, callback);
     }
 
+    /**
+     * Preload metadata for the specified topic to avoid blocking on the first 
send() call.
+     * This method will block until metadata for the topic is available or 
until
+     * max.block.ms timeout is reached.
+     * 
+     * <p>For multiple topics, users can call this method concurrently in 
separate threads
+     * to control parallelism according to their needs.
+     *
+     * @param topic the topic to warm up metadata for
+     * @throws InterruptedException if interrupted while waiting for metadata
+     * @throws TimeoutException if metadata could not be fetched within 
max.block.ms
+     * @throws KafkaException for other errors
+     */
+    @Override
+    public void warmup(String topic) throws InterruptedException {
+        warmup(topic, maxBlockTimeMs);
+    }
+
+    /**
+     * Preload metadata for the specified topic to avoid blocking on the first 
send() call.
+     * This method will block until metadata for the topic is available or 
until
+     * the specified timeout is reached.
+     * 
+     * <p>For multiple topics, users can call this method concurrently in 
separate threads
+     * to control parallelism according to their needs.
+     *
+     * @param topic the topic to warm up metadata for
+     * @param timeoutMs the maximum time to wait for metadata in milliseconds
+     * @throws InterruptedException if interrupted while waiting for metadata
+     * @throws TimeoutException if metadata could not be fetched within the 
timeout
+     * @throws KafkaException for other errors
+     */
+    @Override
+    public void warmup(String topic, long timeoutMs) throws 
InterruptedException {

Review Comment:
   open https://github.com/apache/kafka/pull/20842 for review 
   close this one.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to