linlinnn commented on a change in pull request #10544:
URL: https://github.com/apache/pulsar/pull/10544#discussion_r637719012



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java
##########
@@ -32,6 +32,9 @@
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
+import java.time.Duration;
+import java.util.*;

Review comment:
       please avoid import *

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java
##########
@@ -184,6 +191,50 @@ protected ConsumerBase(PulsarClientImpl client, String 
topic, ConsumerConfigurat
         return internalReceive(timeout, unit);
     }
 
+    @Override
+    public CompletableFuture<Message<T>> receiveAsync(int timeout, TimeUnit 
unit) {
+
+        if (listener != null) {
+            return FutureUtil.failedFuture(new 
PulsarClientException.InvalidConfigurationException(
+                    "Cannot use receive() when a listener has been set"));
+        }
+        try {
+            verifyConsumerState();
+        } catch (PulsarClientException e) {
+            return FutureUtil.failedFuture(e);
+        }
+
+        ScheduledExecutorService messageScheduledFuture = 
Executors.newSingleThreadScheduledExecutor(

Review comment:
       1. In this way, you break the former logic handling the case when queue 
size is not zero.
   2. We just need remove the code below:
   ```
   if (conf.getReceiverQueueSize() == 0) {
       throw new PulsarClientException.InvalidConfigurationException(
               "Can't use receive with timeout, if the queue size is 0");
   }
   ```
   and then override the method `internalReceive(timeout, unit)` in 
`ZeroQueueConsumerImpl`
   3. use single instance of `ScheduledExecutorService`.




-- 
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:
[email protected]


Reply via email to