BewareMyPower commented on code in PR #21417:
URL: https://github.com/apache/pulsar/pull/21417#discussion_r1519330786
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/TableViewImpl.java:
##########
@@ -226,50 +250,115 @@ private void handleMessage(Message<T> msg) {
}
}
}
+ checkAllFreshTask(msg);
} finally {
msg.release();
}
}
- private CompletableFuture<Reader<T>> readAllExistingMessages(Reader<T>
reader) {
+ @Override
+ public CompletableFuture<Void> refreshAsync() {
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ reader.thenCompose(reader ->
getLastMessageIds(reader).thenAccept(lastMessageIds -> {
+ // After get the response of lastMessageIds, put the future and
result into `refreshMap`
+ // and then filter out partitions that has been read to the
lastMessageID.
+ refreshRequests.put(completableFuture, lastMessageIds);
+ filterReceivedMessages(lastMessageIds);
+ // If there is no new messages, the refresh operation could be
completed right now.
+ if (lastMessageIds.isEmpty()) {
+ refreshRequests.remove(completableFuture);
+ completableFuture.complete(null);
+ }
+ })).exceptionally(throwable -> {
+ completableFuture.completeExceptionally(throwable);
+ refreshRequests.remove(completableFuture);
+ return null;
+ });
+ return completableFuture;
+ }
+
+ @Override
+ public void refresh() throws PulsarClientException {
+ refreshAsync().join();
Review Comment:
You should not call `join()` here. Instead, you should wrap the exception of
`refreshAsync` to the `PulsarClientException`. See
`ConsumerImpl#hasMessageAvailable` for example.
--
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]