pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] sijie commented on a change in pull request #3622: add reset cousor to a specific message time
Date Thu, 21 Feb 2019 02:55:48 GMT
sijie commented on a change in pull request #3622: add reset cousor to a specific message time
URL: https://github.com/apache/pulsar/pull/3622#discussion_r258554266
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
 ##########
 @@ -1400,6 +1400,45 @@ public void seek(MessageId messageId) throws PulsarClientException
{
         }
     }
 
+    @Override
+    public void seek(long timestamp) throws PulsarClientException {
+        try {
+            seekAsync(timestamp).get();
+        } catch (ExecutionException | InterruptedException e) {
+            throw new PulsarClientException(e);
+        }
+    }
+
+    @Override
+    public CompletableFuture<Void> seekAsync(long timestamp) {
+        if (getState() == State.Closing || getState() == State.Closed) {
+            return FutureUtil
+                    .failedFuture(new PulsarClientException.AlreadyClosedException("Consumer
was already closed"));
+        }
+
+        if (!isConnected()) {
+            return FutureUtil.failedFuture(new PulsarClientException("Not connected to broker"));
+        }
+
+        final CompletableFuture<Void> seekFuture = new CompletableFuture<>();
+
+        long requestId = client.newRequestId();
+        ByteBuf seek = Commands.newSeek(consumerId, requestId, timestamp);
+        ClientCnx cnx = cnx();
+
+        log.info("[{}][{}] Seek subscription to message time {}", topic, subscription, timestamp);
 
 Review comment:
   nit: I would suggest changing `message time` to `publish time`. `message time` is ambiguous.


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