<@U078Y59KC3B> is there any REST API endpoint that...
# ask-ai
m
@RunLLM is there any REST API endpoint that will tell total number of un-consumed messages in any given topic? There are no subscribers/consumers yet.
r
Yes, you can get the total number of unconsumed (backlog) messages for a topic using the Pulsar Admin REST API endpoint
/admin/v2/:schema/:tenant/:namespace/:topic/stats
. The
msgBacklog
field under each subscription shows the backlog, but if there are no subscriptions, the backlog is effectively zero since Pulsar only tracks backlog per subscription, not globally. If no consumers/subscriptions exist, there is no backlog to report for the topic itself—backlog is only counted once a subscription is created. See Pulsar Admin API - Stats. Would you like more detail on how backlog is tracked or how to use the API? Sources: - Pulsar Admin API - Stats 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
m
@RunLLM is there any other way to know what are the total number of un consumed messages in topic?
r
No, there is no other way to get the total number of unconsumed messages in a topic without at least one subscription, because Pulsar tracks backlog per subscription, not at the topic level. If there are no subscriptions, Pulsar does not maintain or expose a count of unconsumed messages for the topic as a whole. See Pulsar Admin API - Stats. Would you like more detail on Pulsar's message tracking model? Sources: - Pulsar Admin API - Stats 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
m
@RunLLM, what if the producer created a topic dynamically, and not all the consumers need to subscribe to that topic?
r
If a producer creates a topic dynamically and not all consumers subscribe, only the consumers with subscriptions on that topic will have backlog tracked for them. Pulsar does not track a global backlog; unconsumed messages are only counted per subscription. If a topic has no subscriptions, there is no backlog reported for it, even if messages exist on the topic. See Pulsar Concepts - How to use. Would you like more detail on how Pulsar handles dynamic topics and consumer subscriptions? Sources: - Pulsar Concepts - How to use 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.