You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/08/23 04:47:18 UTC

[GitHub] [pulsar] lhotari commented on a diff in pull request #17182: [improve][java-client] check consumer pause status before consumer receive/batchReceive

lhotari commented on code in PR #17182:
URL: https://github.com/apache/pulsar/pull/17182#discussion_r952144456


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java:
##########
@@ -228,7 +233,9 @@ public CompletableFuture<Message<T>> receiveAsync() {
         } catch (PulsarClientException e) {
             return FutureUtil.failedFuture(e);
         }
-        return internalReceiveAsync();
+        return pauseFuture.thenCompose((v) -> {
+            return internalReceiveAsync();
+        });

Review Comment:
   The solution would need to be optimized. Although using a CompletableFuture addresses the functional aspects, it's not optimal at all. For example, in this case, `.thenCompose` will create new objects on every call, also when pausing is disabled. 



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org