Search code examples
apache-pulsar

Pulsar - get number of unacked messages on a subscription


While playing with pulsar we have sent 100.000.000 messages to a topic with an existing subscription.

The storage went up by numbers that we would have expected enter image description here

But we are wondering about the output of the pulsar-admin stats command, as it seems to see only 93337 messages on the backlog.

root@pulsar:/pulsar/bin# ./pulsar-admin topics stats persistent://public/default/standalone
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 2346125445,
  "msgInCounter" : 15542302,
  "bytesOutCounter" : 0,
  "msgOutCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 2346125445,
  "backlogSize" : 1942675515,
  "publishers" : [ ],
  "subscriptions" : {
    "sub1" : {
      "msgRateOut" : 0.0,
      "msgThroughputOut" : 0.0,
      "bytesOutCounter" : 0,
      "msgOutCounter" : 0,
      "msgRateRedeliver" : 0.0,
      "chuckedMessageRate" : 0,
      "msgBacklog" : 93337,
      "msgBacklogNoDelayed" : 93337,
      "blockedSubscriptionOnUnackedMsgs" : false,
      "msgDelayed" : 0,
      "unackedMessages" : 0,
      "type" : "Exclusive",
      "msgRateExpired" : 0.0,
      "lastExpireTimestamp" : 0,
      "lastConsumedFlowTimestamp" : 1700123065831,
      "lastConsumedTimestamp" : 0,
      "lastAckedTimestamp" : 0,
      "consumers" : [ ],
      "isDurable" : true,
      "isReplicated" : false
    }
  },
  "replication" : { },
  "deduplicationStatus" : "Disabled"
}

Are we mixing something up?


Solution

  • You probably have batching enabled (default). msgBacklog reports the number of entries/batches and by default a batch is ~1000 messages. So if that's the case, the numbers look coherent.