sijie 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_r279611149
##########
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:
@murong00 yes it requires a PIP if it touches data format or wire protocol
or user-facing interfaces. I am happy to help you if you need some helps.
----------------------------------------------------------------
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