pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ivankelly commented on a change in pull request #2103: Issue 1433: Expose batch flushAsync() and flush() methods in Producer
Date Mon, 09 Jul 2018 10:50:38 GMT
ivankelly commented on a change in pull request #2103: Issue 1433: Expose batch flushAsync()
and flush() methods in Producer
URL: https://github.com/apache/incubator-pulsar/pull/2103#discussion_r200954861
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
 ##########
 @@ -1218,7 +1223,22 @@ public void run(Timeout timeout) throws Exception {
     };
 
     @Override
-    protected void flush() {
+    public CompletableFuture<Void> flushAsync() {
+        if (isBatchMessagingEnabled()) {
+            CompletableFuture<MessageId> lastSendFuture;
+            synchronized (ProducerImpl.this) {
+                batchMessageAndSend();
+                lastSendFuture = this.lastSendFuture;
+            }
+            if (null != lastSendFuture) {
+                return lastSendFuture.thenApply(ignored -> null);
+            }
+        }
+        return CompletableFuture.completedFuture(null);
 
 Review comment:
   If you initialize lastSendFuture to CompletableFuture.completedFuture(null), you don't
need the null check. Also, if batching is not enabled, you should still be waiting on lastSendFuture
from the previous asyncSend (not sure if this is what you're referring to in your comment
above).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message