murong00 commented on a change in pull request #4168: [Issue 4167] 
[pulsar-broker] Support to get the number of current messages
URL: https://github.com/apache/pulsar/pull/4168#discussion_r279621321
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
 ##########
 @@ -1522,4 +1525,38 @@ protected MessageId internalGetLastMessageId(boolean 
authoritative) {
 
         return messageId;
     }
+
+    protected long internalGetMessageCount(boolean authoritative) {
+        validateAdminOperationOnTopic(authoritative);
+
+        if (!(getTopicReference(topicName) instanceof PersistentTopic)) {
+            log.error("[{}] Not supported operation of non-persistent topic 
{}", clientAppId(), topicName);
+            throw new RestException(Status.METHOD_NOT_ALLOWED,
+                "GetMessageCount on a non-persistent topic is not allowed");
+        }
+
+        Reader<byte[]> reader = null;
+        final AtomicLong count = new AtomicLong();
+
+        try {
+            reader = pulsar().getClient().newReader()
 
 Review comment:
   okay, thanks a lot. I'll seek advice from you if I plan to try. Just close 
this PR to leave the issue free to others.

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