leiless edited a comment on issue #10832: URL: https://github.com/apache/pulsar/issues/10832#issuecomment-858341525
Code example ```java List<CompletableFuture<MessageId>> sendFutureList = Lists.newArrayList(); for (int i = 0; i < numMsgs; i++) { byte[] message = ("msg-" + i).getBytes(); sendFutureList.add(producer.sendAsync(message)); if ((i + 1) % numMsgsInBatch == 0) { producer.flush(); LOG.info("Flush {} messages", (i + 1)); } } FutureUtil.waitForAll(sendFutureList).get(); ``` https://github.com/apache/pulsar/blob/master/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java#L340-L349 https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java#L36-L44 -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org