sijie commented on a change in pull request #6331: [Issue 2912][pulsar-admin]
add get-message-by-id cmd into pulsar-admin
URL: https://github.com/apache/pulsar/pull/6331#discussion_r380427210
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -1495,6 +1496,43 @@ protected void internalResetCursorOnPosition(String
subName, boolean authoritati
}
}
+ protected void internalGetMessageById(AsyncResponse asyncResponse, long
ledgerId, long entryId,
+ boolean authoritative) {
+ verifyReadOperation(authoritative);
+
+ PersistentTopic topic = (PersistentTopic) getTopicReference(topicName);
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl)
topic.getManagedLedger();
+ Entry entry = null;
+ try {
+ CompletableFuture<Entry> future = new CompletableFuture<>();
+ ledger.asyncReadEntry(new PositionImpl(ledgerId, entryId), new
AsyncCallbacks.ReadEntryCallback() {
+ @Override
+ public void readEntryFailed(ManagedLedgerException exception,
Object ctx) {
+ asyncResponse.resume(new RestException(exception));
+ }
+
+ @Override
+ public void readEntryComplete(Entry entry, Object ctx) {
+ try {
+ asyncResponse.resume(generateResponseWithEntry(entry));
+ } catch (IOException exception) {
+ asyncResponse.resume(new RestException(exception));
+ }
+ }
+ }, null);
+ } catch (NullPointerException npe) {
+ asyncResponse.resume(new RestException(Status.NOT_FOUND, "Message
not found"));
+ } catch (Exception exception) {
+ log.error("[{}] Failed to get message with ledgerId {} entryId {}
from {}",
+ clientAppId(), ledgerId, entryId, topicName, exception);
+ asyncResponse.resume(new RestException(exception));
+ } finally {
+ if (entry != null) {
Review comment:
move this `finally` block to line 1520
----------------------------------------------------------------
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]
With regards,
Apache Git Services