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

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
 ##########
 @@ -1403,21 +1403,47 @@ protected void internalResetCursorOnPosition(String 
subName, boolean authoritati
         }
     }
 
-    protected Response internalPeekNthMessage(String subName, int 
messagePosition, boolean authoritative) {
-        if (topicName.isGlobal()) {
-            validateGlobalNamespaceOwnership(namespaceName);
-        }
-        PartitionedTopicMetadata partitionMetadata = 
getPartitionedTopicMetadata(topicName, authoritative, false);
-        if (partitionMetadata.partitions > 0) {
-            throw new RestException(Status.METHOD_NOT_ALLOWED, "Peek messages 
on a partitioned topic is not allowed");
+    protected Response internalGetMessageById(long ledgerId, long entryId, 
boolean authoritative) {
+        verifyReadOperation(authoritative);
+
+        String subName = "get-message-id-" + UUID.randomUUID().toString();
+        PersistentTopic topic = (PersistentTopic) getTopicReference(topicName);
+
+        Entry entry = null;
+        try {
+            PersistentSubscription subscription =
+                    (PersistentSubscription) topic.createSubscription(subName, 
InitialPosition.Earliest, false).get();
 
 Review comment:
   Same as comments above
   

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

Reply via email to