poorbarcode commented on code in PR #17443:
URL: https://github.com/apache/pulsar/pull/17443#discussion_r969114272


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -789,20 +804,31 @@ public CompletableFuture<Void> seekAsync(MessageId 
messageId) {
                     new PulsarClientException("Illegal messageId, messageId 
can only be earliest/latest")
             );
         }
-        List<CompletableFuture<Void>> futures = new 
ArrayList<>(consumers.size());
-        consumers.values().forEach(consumerImpl -> 
futures.add(consumerImpl.seekAsync(targetMessageId)));
-
-        unAckedMessageTracker.clear();
-        clearIncomingMessages();
-
-        return FutureUtil.waitForAll(futures);
+        return internalSeekAsync(consumer -> consumer.seekAsync(messageId));
     }
 
     @Override
     public CompletableFuture<Void> seekAsync(long timestamp) {
-        List<CompletableFuture<Void>> futures = new 
ArrayList<>(consumers.size());
-        consumers.values().forEach(consumer -> 
futures.add(consumer.seekAsync(timestamp)));
-        return FutureUtil.waitForAll(futures);
+        return internalSeekAsync(consumer -> consumer.seekAsync(timestamp));
+    }
+
+    private CompletableFuture<Void> internalSeekAsync(Function<Consumer, 
CompletableFuture<Void>> childSeekFunction) {
+        pause();
+        CompletableFuture<Void> res = 
FutureUtil.waitForAll(receiveMessageFutures).thenCompose(__ -> {

Review Comment:
   Good suggestion, but we don't have the operability of `cancel`, and the 
waiting-event only happens on this scenario:  call `seek` multi times quickly, 
along with `read`, this is very rare.



-- 
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