跳转到正文

Apache Pulsar 运维与观测 ​

本页结论:看懂三个信号就能覆盖大多数 Pulsar 日常问题——订阅 backlog(积压)、进出速率、bookie 写入健康;日常操作靠 pulsar-admin(查 stats/backlog、列订阅、reset-cursor 回放)。本仓库实验仅绑定 127.0.0.1,不开认证。

管理接口 ​

工具用途
pulsar-adminTopic/订阅/命名空间管理:stats、backlog、reset-cursor、策略配置
pulsar-client命令行手工 produce/consume 调试
HTTP Admin APIhttp://127.0.0.1:8080,pulsar-admin 的底层 REST 接口
/metricsBroker 的 Prometheus 指标端点(同 8080 端口)
bin/pulsar-admin brokers healthcheck存活自检(compose healthcheck 即用它)

本仓库 lab 在容器内调用(示例,回放见 redelivery-replay 实验):

bash
# 列出订阅
docker compose -p hello-mq-pulsar-basic exec pulsar \
  bin/pulsar-admin topics subscriptions persistent://public/default/orders-basic

# 订阅级状态:cursor 位置、msgBacklog、msgRateOut(JSON)
docker compose -p hello-mq-pulsar-basic exec pulsar \
  bin/pulsar-admin topics stats persistent://public/default/orders-basic

# 只看积压大小
docker compose -p hello-mq-pulsar-basic exec pulsar \
  bin/pulsar-admin topics backlog persistent://public/default/orders-basic

# 重置游标到最早位置(全量回放);也支持 latest / MessageId / 时间戳
docker compose -p hello-mq-pulsar-redelivery-replay exec pulsar \
  bin/pulsar-admin topics reset-cursor persistent://public/default/orders-redeliver \
  --subscription <sub> --reset-position earliest

# 查看命名空间保留策略
docker compose -p hello-mq-pulsar-basic exec pulsar \
  bin/pulsar-admin namespaces policies public/default

核心指标 ​

指标(Prometheus 示例名)含义异常信号
pulsar_msg_backlog(按订阅)该订阅未消费消息数持续增长 = 消费跟不上生产(积压),见 背压与积压
pulsar_rate_in / pulsar_rate_outTopic 进/出消息速率out 骤降而 in 平稳 = 消费侧故障
pulsar_storage_sizeTopic 占用存储逼近磁盘水位 = 该调 retention/TTL 或扩容 bookie
未 ack 消息数 / 重投速率消费处理健康度重投速率飙升 = 毒消息循环或下游超时
BookKeeper 写入延迟 / 失败存储层健康写延迟抖动 = bookie 磁盘或 quorum 不足

补充观测点:

  • reset-cursor 是双刃剑:回放会把 backlog 瞬间拉满并触发重复投递,执行前确认消费端幂等(redelivery-replay 实验 即此场景)。
  • DLQ 深度:<topic>-<sub>-DLQ 有消息 = 有处理失败被隔离,需要告警与处置流程。
  • 端到端延迟:消息 event time 与消费时刻之差,比 backlog 更贴近业务感受。

追踪传播 ​

本仓库 Demo 把 traceId、eventType、aggregateId 写入消息 properties,消费端日志原样带出;一条消息在 producer/consumer 两端可用同一 traceId 关联。生产环境可接 OpenTelemetry:producer 注入 properties,consumer 恢复 context。

常见故障速查 ​

现象先查什么
backlog 持续上涨消费者是否存活;是否卡在毒消息(无 DeadLetterPolicy 时无限重投)
生产超时/失败bookie 写入是否健康;quorum 是否不足;Broker 是否饱和
消息「重复」ack 是否早于业务提交;生产者重试是否重复写入;是否刚执行过 reset-cursor
消息「看不到」TTL 是否先于消费删除;订阅 cursor 是否被重置过;是否消费了错误的订阅名
第二个消费者连不上Exclusive 订阅的排他语义:冲突报错是预期行为,换 Shared/Key_Shared
standalone 健康检查超时冷启动需 60–120s;确认等待上限 ≥180s 且机器资源够(堆 512m + 直接内存 256m 起)

安全基线(standalone 实验版) ​

  • 本仓库实验不开认证:6650(pulsar)与 8080(管理)仅绑定 127.0.0.1——仅限学习用途。
  • 生产基线:TLS 传输加密 + 认证(JWT/OAuth2/客户端证书)、tenant/namespace/topic 层级授权最小化、审计日志;管理 API 与元数据服务端口不暴露公网。
  • standalone 单容器(broker+bookie+元数据合一)不等价生产集群:生产应三层分离部署、元数据服务奇数节点、bookie 磁盘与 quorum 独立规划。

cli-tools:纯自带 CLI 实验 ​

standalone 镜像 bin 目录共 19 项,pulsar-admin 与 pulsar-client 即可完成收发闭环:brokers healthcheck 体检 → topics create 建 non-partitioned Topic → pulsar-client produce -m 以逗号分隔一次拆成 3 条消息 → consume -n 3 --subscription-position Earliest 收满自动退出。最后 topics stats 复查 msgInCounter=3、msgBacklog=0,全程不引入任何客户端 SDK。

pulsar / dockerbash demos/pulsar/docker/run.sh
assert.out.txt
---
status: verified
capturedAt: "2026-08-23T15:19:49.324Z"
dockerImage: "apachepulsar/pulsar:4.2.4@sha256:cd5d4a64a32c0770d5d2dbb526169a70081605bbec4b59b73471b68d0a451fb4"
exitCode: 0
---
PASS binCount: 19
PASS healthCheck: 1
PASS statsAfterCreate: 1
PASS producedMsgCount: 3
PASS consumedMsgCount: 3
PASS consumedCount: 3
PASS msgInCounter: 3
PASS msgBacklog: 0
PASS subscriptionListed: 1
RESULT: all assertions passed
bin-list.out.txt
[cli-tools] $ ls /pulsar/bin
apply-config-from-env-with-prefix.py
apply-config-from-env.py
bookkeeper
function-localrunner
gen-yml-from-env.py
generate-zookeeper-config.sh
proto
pulsar
pulsar-admin
pulsar-admin-common.sh
pulsar-client
pulsar-daemon
pulsar-managed-ledger-admin
pulsar-perf
pulsar-shell
pulsar-zookeeper-ruok.sh
update-ini-from-env.py
update-rocksdb-conf-from-env.py
watch-znode.py
consume.out.txt
[cli-tools] $ sh -c timeout -k 5 120 bin/pulsar-client consume -n 3 -s orders-cli-sub   --subscription-position Earliest persistent://public/default/orders-cli; rc=$?; if [ $rc -ne 0 ] && [ $rc -ne 124 ]; then exit $rc; fi
Aug 23, 2026 3:17:56 PM io.opentelemetry.api.GlobalOpenTelemetry maybeAutoConfigureAndSetGlobal
INFO: AutoConfiguredOpenTelemetrySdk found on classpath but automatic configuration is disabled. To enable, run your JVM with -Dotel.java.global-autoconfigure.enabled=true
2026-08-23T15:17:57,226+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConnectionPool - [[id: 0x60e478e9, L:/127.0.0.1:38930 - R:localhost/127.0.0.1:6650]] Connected to server {}
2026-08-23T15:17:57,420+0000 [pulsar-client-lookup-15-1] INFO  org.apache.pulsar.client.impl.ConsumerStatsRecorderImpl - Starting Pulsar consumer status recorder with config: {"topicNames":["persistent://public/default/orders-cli"],"topicsPattern":null,"subscriptionName":"orders-cli-sub","subscriptionType":"Exclusive","subscriptionProperties":null,"subscriptionMode":"Durable","receiverQueueSize":1000,"acknowledgementsGroupTimeMicros":100000,"maxAcknowledgmentGroupSize":1000,"negativeAckRedeliveryDelayMicros":60000000,"negativeAckPrecisionBitCnt":8,"maxTotalReceiverQueueSizeAcrossPartitions":50000,"consumerName":null,"ackTimeoutMillis":0,"tickDurationMillis":1000,"priorityLevel":0,"maxPendingChunkedMessage":10,"autoAckOldestChunkedMessageOnQueueFull":false,"expireTimeOfIncompleteChunkedMessageMillis":60000,"cryptoFailureAction":"FAIL","properties":{},"readCompacted":false,"subscriptionInitialPosition":"Earliest","patternAutoDiscoveryPeriod":60,"regexSubscriptionMode":"PersistentOnly","deadLetterPolicy":null,"retryEnable":false,"autoUpdatePartitions":true,"autoUpdatePartitionsIntervalSeconds":60,"replicateSubscriptionState":false,"resetIncludeHead":false,"batchIndexAckEnabled":true,"ackReceiptEnabled":false,"poolMessages":true,"startPaused":false,"autoScaledReceiverQueueSizeEnabled":false,"topicConfigurations":[],"maxPendingChuckedMessage":10} {}
2026-08-23T15:17:57,444+0000 [pulsar-client-lookup-15-1] INFO  org.apache.pulsar.client.impl.ConsumerStatsRecorderImpl - Pulsar client config: {"serviceUrl":"pulsar://localhost:6650/","serviceUrlQuarantineInitDurationMs":60000,"serviceUrlQuarantineMaxDurationMs":86400000,"authPluginClassName":null,"authParams":null,"authParamMap":null,"originalPrincipal":null,"operationTimeoutMs":30000,"lookupTimeoutMs":30000,"statsIntervalSeconds":60,"numIoThreads":4,"numListenerThreads":4,"connectionsPerBroker":1,"connectionMaxIdleSeconds":60,"useTcpNoDelay":true,"useTls":false,"tlsKeyFilePath":"","tlsCertificateFilePath":"","tlsTrustCertsFilePath":"","tlsAllowInsecureConnection":false,"tlsHostnameVerificationEnable":false,"sslFactoryPlugin":"org.apache.pulsar.common.util.DefaultPulsarSslFactory","sslFactoryPluginParams":null,"concurrentLookupRequest":5000,"maxLookupRequest":50000,"maxLookupRedirects":20,"maxNumberOfRejectedRequestPerConnection":50,"keepAliveIntervalSeconds":30,"connectionTimeoutMs":10000,"requestTimeoutMs":60000,"readTimeoutMs":60000,"autoCertRefreshSeconds":300,"initialBackoffIntervalNanos":100000000,"maxBackoffIntervalNanos":60000000000,"enableBusyWait":false,"listenerName":null,"useKeyStoreTls":false,"sslProvider":null,"tlsKeyStoreType":"JKS","tlsKeyStorePath":"","tlsKeyStorePassword":"*****","tlsTrustStoreType":"JKS","tlsTrustStorePath":"","tlsTrustStorePassword":"*****","tlsCiphers":[],"tlsProtocols":[],"memoryLimitBytes":0,"proxyServiceUrl":null,"proxyProtocol":null,"enableTransaction":false,"dnsLookupBindAddress":null,"dnsLookupBindPort":0,"dnsServerAddresses":[],"socks5ProxyAddress":null,"socks5ProxyUsername":null,"socks5ProxyPassword":null,"description":null,"lookupProperties":{},"tracingEnabled":false,"openTelemetry":null} {}
2026-08-23T15:17:57,464+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/orders-cli][orders-cli-sub] Subscribing to topic on cnx [id: 0x60e478e9, L:/127.0.0.1:38930 - R:localhost/127.0.0.1:6650], consumerId 0 {}
2026-08-23T15:17:57,478+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/orders-cli][orders-cli-sub] Subscribed to topic on localhost/127.0.0.1:6650 -- consumer: 0 {}
----- got message -----
publishTime:[1787498273257], eventTime:[0], key:[null], properties:[], content:order-cli-1
----- got message -----
publishTime:[1787498273282], eventTime:[0], key:[null], properties:[], content:order-cli-2
----- got message -----
publishTime:[1787498273287], eventTime:[0], key:[null], properties:[], content:order-cli-3
2026-08-23T15:17:57,576+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/orders-cli] [orders-cli-sub] Closed consumer {}
2026-08-23T15:17:57,577+0000 [main] INFO  org.apache.pulsar.client.impl.PulsarClientImpl - Client closing. URL: pulsar://localhost:6650/ {}
2026-08-23T15:17:57,586+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ClientCnx - [id: 0x60e478e9, L:/127.0.0.1:38930 ! R:localhost/127.0.0.1:6650] Disconnected {}
2026-08-23T15:17:59,602+0000 [main] INFO  org.apache.pulsar.client.cli.PulsarClientTool - 3 messages successfully consumed {}
create.out.txt
[cli-tools] $ bin/pulsar-admin topics create persistent://public/default/orders-cli
inventory.out.txt
---
status: verified
capturedAt: "2026-08-23T15:19:49.324Z"
dockerImage: "apachepulsar/pulsar:4.2.4@sha256:cd5d4a64a32c0770d5d2dbb526169a70081605bbec4b59b73471b68d0a451fb4"
exitCode: 0
---
[cli-tools] $ ls /pulsar/bin
apply-config-from-env-with-prefix.py
apply-config-from-env.py
bookkeeper
function-localrunner
gen-yml-from-env.py
generate-zookeeper-config.sh
proto
pulsar
pulsar-admin
pulsar-admin-common.sh
pulsar-client
pulsar-daemon
pulsar-managed-ledger-admin
pulsar-perf
pulsar-shell
pulsar-zookeeper-ruok.sh
update-ini-from-env.py
update-rocksdb-conf-from-env.py
watch-znode.py
produce.out.txt
[cli-tools] $ bin/pulsar-client produce -m order-cli-1,order-cli-2,order-cli-3 persistent://public/default/orders-cli
Aug 23, 2026 3:17:52 PM io.opentelemetry.api.GlobalOpenTelemetry maybeAutoConfigureAndSetGlobal
INFO: AutoConfiguredOpenTelemetrySdk found on classpath but automatic configuration is disabled. To enable, run your JVM with -Dotel.java.global-autoconfigure.enabled=true
2026-08-23T15:17:53,012+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConnectionPool - [[id: 0x189dbd4a, L:/127.0.0.1:38926 - R:localhost/127.0.0.1:6650]] Connected to server {}
2026-08-23T15:17:53,195+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - Starting Pulsar producer perf with config: {"topicName":"persistent://public/default/orders-cli","producerName":null,"sendTimeoutMs":30000,"blockIfQueueFull":false,"maxPendingMessages":1000,"maxPendingMessagesAcrossPartitions":50000,"messageRoutingMode":"RoundRobinPartition","hashingScheme":"JavaStringHash","cryptoFailureAction":"FAIL","batchingMaxPublishDelayMicros":1000,"batchingPartitionSwitchFrequencyByPublishDelay":10,"batchingMaxMessages":1000,"batchingMaxBytes":131072,"batchingEnabled":true,"chunkingEnabled":false,"chunkMaxMessageSize":-1,"encryptionKeys":[],"compressionType":"NONE","compressMinMsgBodySize":4096,"initialSequenceId":null,"autoUpdatePartitions":true,"autoUpdatePartitionsIntervalSeconds":60,"multiSchema":true,"accessMode":"Shared","lazyStartPartitionedProducers":false,"properties":{},"initialSubscriptionName":null,"replProducer":false,"nonPartitionedTopicExpected":false} {}
2026-08-23T15:17:53,221+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - Pulsar client config: {"serviceUrl":"pulsar://localhost:6650/","serviceUrlQuarantineInitDurationMs":60000,"serviceUrlQuarantineMaxDurationMs":86400000,"authPluginClassName":null,"authParams":null,"authParamMap":null,"originalPrincipal":null,"operationTimeoutMs":30000,"lookupTimeoutMs":30000,"statsIntervalSeconds":60,"numIoThreads":4,"numListenerThreads":4,"connectionsPerBroker":1,"connectionMaxIdleSeconds":60,"useTcpNoDelay":true,"useTls":false,"tlsKeyFilePath":"","tlsCertificateFilePath":"","tlsTrustCertsFilePath":"","tlsAllowInsecureConnection":false,"tlsHostnameVerificationEnable":false,"sslFactoryPlugin":"org.apache.pulsar.common.util.DefaultPulsarSslFactory","sslFactoryPluginParams":null,"concurrentLookupRequest":5000,"maxLookupRequest":50000,"maxLookupRedirects":20,"maxNumberOfRejectedRequestPerConnection":50,"keepAliveIntervalSeconds":30,"connectionTimeoutMs":10000,"requestTimeoutMs":60000,"readTimeoutMs":60000,"autoCertRefreshSeconds":300,"initialBackoffIntervalNanos":100000000,"maxBackoffIntervalNanos":60000000000,"enableBusyWait":false,"listenerName":null,"useKeyStoreTls":false,"sslProvider":null,"tlsKeyStoreType":"JKS","tlsKeyStorePath":"","tlsKeyStorePassword":"*****","tlsTrustStoreType":"JKS","tlsTrustStorePath":"","tlsTrustStorePassword":"*****","tlsCiphers":[],"tlsProtocols":[],"memoryLimitBytes":0,"proxyServiceUrl":null,"proxyProtocol":null,"enableTransaction":false,"dnsLookupBindAddress":null,"dnsLookupBindPort":0,"dnsServerAddresses":[],"socks5ProxyAddress":null,"socks5ProxyUsername":null,"socks5ProxyPassword":null,"description":null,"lookupProperties":{},"tracingEnabled":false,"openTelemetry":null} {}
2026-08-23T15:17:53,234+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerImpl - [persistent://public/default/orders-cli] [null] Creating producer on cnx [id: 0x189dbd4a, L:/127.0.0.1:38926 - R:localhost/127.0.0.1:6650] {}
2026-08-23T15:17:53,243+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerImpl - [persistent://public/default/orders-cli] [standalone-0-3] Created producer on cnx [id: 0x189dbd4a, L:/127.0.0.1:38926 - R:localhost/127.0.0.1:6650] {}
2026-08-23T15:17:53,295+0000 [main] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - [persistent://public/default/orders-cli] [standalone-0-3] --- Publish throughput: 43.37 msg/s --- 0.00 Mbit/s --- Latency: med: 3.000 ms - 95pct: 26.000 ms - 99pct: 26.000 ms - 99.9pct: 26.000 ms - max: 26.000 ms --- BatchSize: med: 1.000 - 95pct: 1.000 - 99pct: 1.000 - 99.9pct: 1.000 - max: 1.000 --- MsgSize: med: 11.000 bytes - 95pct: 11.000 bytes - 99pct: 11.000 bytes - 99.9pct: 11.000 bytes - max: 11.000 bytes --- Ack received rate: 43.37 ack/s --- Failed messages: 0 --- Pending messages: 0 {}
2026-08-23T15:17:53,298+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerImpl - [persistent://public/default/orders-cli] [standalone-0-3] Closed Producer {}
2026-08-23T15:17:53,300+0000 [main] INFO  org.apache.pulsar.client.impl.PulsarClientImpl - Client closing. URL: pulsar://localhost:6650/ {}
2026-08-23T15:17:53,306+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ClientCnx - [id: 0x189dbd4a, L:/127.0.0.1:38926 ! R:localhost/127.0.0.1:6650] Disconnected {}
2026-08-23T15:17:55,316+0000 [main] INFO  org.apache.pulsar.client.cli.PulsarClientTool - 3 messages successfully produced {}
session.out.txt
---
status: verified
capturedAt: "2026-08-23T15:19:49.324Z"
dockerImage: "apachepulsar/pulsar:4.2.4@sha256:cd5d4a64a32c0770d5d2dbb526169a70081605bbec4b59b73471b68d0a451fb4"
exitCode: 0
---
## status
[cli-tools] $ bin/pulsar-admin brokers healthcheck
ok
[cli-tools] $ bin/pulsar-admin topics stats persistent://public/default/orders-cli
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 0,
  "msgInCounter" : 0,
  "systemTopicBytesInCounter" : 0,
  "bytesOutCounter" : 0,
  "msgOutCounter" : 0,
  "bytesOutInternalCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 0,
  "backlogSize" : 0,
  "backlogQuotaLimitSize" : 10737418240,
  "backlogQuotaLimitTime" : -1,
  "oldestBacklogMessageAgeSeconds" : -1,
  "publishRateLimitedTimes" : 0,
  "earliestMsgPublishTimeInBacklogs" : 0,
  "offloadedStorageSize" : 0,
  "lastOffloadLedgerId" : 0,
  "lastOffloadSuccessTimeStamp" : 0,
  "lastOffloadFailureTimeStamp" : 0,
  "ongoingTxnCount" : 0,
  "abortedTxnCount" : 0,
  "committedTxnCount" : 0,
  "publishers" : [ ],
  "waitingPublishers" : 0,
  "subscriptions" : { },
  "replication" : { },
  "deduplicationStatus" : "Disabled",
  "nonContiguousDeletedMessagesRanges" : 0,
  "nonContiguousDeletedMessagesRangesSerializedSize" : 0,
  "delayedMessageIndexSizeInBytes" : 0,
  "compaction" : {
    "lastCompactionRemovedEventCount" : 0,
    "lastCompactionSucceedTimestamp" : 0,
    "lastCompactionFailedTimestamp" : 0,
    "lastCompactionDurationTimeInMills" : 0
  },
  "ownerBroker" : "localhost:8080",
  "topicCreationTimeStamp" : 1787498265476,
  "lastPublishTimeStamp" : 0
}

## create
[cli-tools] $ bin/pulsar-admin topics create persistent://public/default/orders-cli

## produce
[cli-tools] $ bin/pulsar-client produce -m order-cli-1,order-cli-2,order-cli-3 persistent://public/default/orders-cli
Aug 23, 2026 3:17:52 PM io.opentelemetry.api.GlobalOpenTelemetry maybeAutoConfigureAndSetGlobal
INFO: AutoConfiguredOpenTelemetrySdk found on classpath but automatic configuration is disabled. To enable, run your JVM with -Dotel.java.global-autoconfigure.enabled=true
2026-08-23T15:17:53,012+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConnectionPool - [[id: 0x189dbd4a, L:/127.0.0.1:38926 - R:localhost/127.0.0.1:6650]] Connected to server {}
2026-08-23T15:17:53,195+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - Starting Pulsar producer perf with config: {"topicName":"persistent://public/default/orders-cli","producerName":null,"sendTimeoutMs":30000,"blockIfQueueFull":false,"maxPendingMessages":1000,"maxPendingMessagesAcrossPartitions":50000,"messageRoutingMode":"RoundRobinPartition","hashingScheme":"JavaStringHash","cryptoFailureAction":"FAIL","batchingMaxPublishDelayMicros":1000,"batchingPartitionSwitchFrequencyByPublishDelay":10,"batchingMaxMessages":1000,"batchingMaxBytes":131072,"batchingEnabled":true,"chunkingEnabled":false,"chunkMaxMessageSize":-1,"encryptionKeys":[],"compressionType":"NONE","compressMinMsgBodySize":4096,"initialSequenceId":null,"autoUpdatePartitions":true,"autoUpdatePartitionsIntervalSeconds":60,"multiSchema":true,"accessMode":"Shared","lazyStartPartitionedProducers":false,"properties":{},"initialSubscriptionName":null,"replProducer":false,"nonPartitionedTopicExpected":false} {}
2026-08-23T15:17:53,221+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - Pulsar client config: {"serviceUrl":"pulsar://localhost:6650/","serviceUrlQuarantineInitDurationMs":60000,"serviceUrlQuarantineMaxDurationMs":86400000,"authPluginClassName":null,"authParams":null,"authParamMap":null,"originalPrincipal":null,"operationTimeoutMs":30000,"lookupTimeoutMs":30000,"statsIntervalSeconds":60,"numIoThreads":4,"numListenerThreads":4,"connectionsPerBroker":1,"connectionMaxIdleSeconds":60,"useTcpNoDelay":true,"useTls":false,"tlsKeyFilePath":"","tlsCertificateFilePath":"","tlsTrustCertsFilePath":"","tlsAllowInsecureConnection":false,"tlsHostnameVerificationEnable":false,"sslFactoryPlugin":"org.apache.pulsar.common.util.DefaultPulsarSslFactory","sslFactoryPluginParams":null,"concurrentLookupRequest":5000,"maxLookupRequest":50000,"maxLookupRedirects":20,"maxNumberOfRejectedRequestPerConnection":50,"keepAliveIntervalSeconds":30,"connectionTimeoutMs":10000,"requestTimeoutMs":60000,"readTimeoutMs":60000,"autoCertRefreshSeconds":300,"initialBackoffIntervalNanos":100000000,"maxBackoffIntervalNanos":60000000000,"enableBusyWait":false,"listenerName":null,"useKeyStoreTls":false,"sslProvider":null,"tlsKeyStoreType":"JKS","tlsKeyStorePath":"","tlsKeyStorePassword":"*****","tlsTrustStoreType":"JKS","tlsTrustStorePath":"","tlsTrustStorePassword":"*****","tlsCiphers":[],"tlsProtocols":[],"memoryLimitBytes":0,"proxyServiceUrl":null,"proxyProtocol":null,"enableTransaction":false,"dnsLookupBindAddress":null,"dnsLookupBindPort":0,"dnsServerAddresses":[],"socks5ProxyAddress":null,"socks5ProxyUsername":null,"socks5ProxyPassword":null,"description":null,"lookupProperties":{},"tracingEnabled":false,"openTelemetry":null} {}
2026-08-23T15:17:53,234+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerImpl - [persistent://public/default/orders-cli] [null] Creating producer on cnx [id: 0x189dbd4a, L:/127.0.0.1:38926 - R:localhost/127.0.0.1:6650] {}
2026-08-23T15:17:53,243+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerImpl - [persistent://public/default/orders-cli] [standalone-0-3] Created producer on cnx [id: 0x189dbd4a, L:/127.0.0.1:38926 - R:localhost/127.0.0.1:6650] {}
2026-08-23T15:17:53,295+0000 [main] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - [persistent://public/default/orders-cli] [standalone-0-3] --- Publish throughput: 43.37 msg/s --- 0.00 Mbit/s --- Latency: med: 3.000 ms - 95pct: 26.000 ms - 99pct: 26.000 ms - 99.9pct: 26.000 ms - max: 26.000 ms --- BatchSize: med: 1.000 - 95pct: 1.000 - 99pct: 1.000 - 99.9pct: 1.000 - max: 1.000 --- MsgSize: med: 11.000 bytes - 95pct: 11.000 bytes - 99pct: 11.000 bytes - 99.9pct: 11.000 bytes - max: 11.000 bytes --- Ack received rate: 43.37 ack/s --- Failed messages: 0 --- Pending messages: 0 {}
2026-08-23T15:17:53,298+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ProducerImpl - [persistent://public/default/orders-cli] [standalone-0-3] Closed Producer {}
2026-08-23T15:17:53,300+0000 [main] INFO  org.apache.pulsar.client.impl.PulsarClientImpl - Client closing. URL: pulsar://localhost:6650/ {}
2026-08-23T15:17:53,306+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ClientCnx - [id: 0x189dbd4a, L:/127.0.0.1:38926 ! R:localhost/127.0.0.1:6650] Disconnected {}
2026-08-23T15:17:55,316+0000 [main] INFO  org.apache.pulsar.client.cli.PulsarClientTool - 3 messages successfully produced {}

## consume
[cli-tools] $ sh -c timeout -k 5 120 bin/pulsar-client consume -n 3 -s orders-cli-sub   --subscription-position Earliest persistent://public/default/orders-cli; rc=$?; if [ $rc -ne 0 ] && [ $rc -ne 124 ]; then exit $rc; fi
Aug 23, 2026 3:17:56 PM io.opentelemetry.api.GlobalOpenTelemetry maybeAutoConfigureAndSetGlobal
INFO: AutoConfiguredOpenTelemetrySdk found on classpath but automatic configuration is disabled. To enable, run your JVM with -Dotel.java.global-autoconfigure.enabled=true
2026-08-23T15:17:57,226+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConnectionPool - [[id: 0x60e478e9, L:/127.0.0.1:38930 - R:localhost/127.0.0.1:6650]] Connected to server {}
2026-08-23T15:17:57,420+0000 [pulsar-client-lookup-15-1] INFO  org.apache.pulsar.client.impl.ConsumerStatsRecorderImpl - Starting Pulsar consumer status recorder with config: {"topicNames":["persistent://public/default/orders-cli"],"topicsPattern":null,"subscriptionName":"orders-cli-sub","subscriptionType":"Exclusive","subscriptionProperties":null,"subscriptionMode":"Durable","receiverQueueSize":1000,"acknowledgementsGroupTimeMicros":100000,"maxAcknowledgmentGroupSize":1000,"negativeAckRedeliveryDelayMicros":60000000,"negativeAckPrecisionBitCnt":8,"maxTotalReceiverQueueSizeAcrossPartitions":50000,"consumerName":null,"ackTimeoutMillis":0,"tickDurationMillis":1000,"priorityLevel":0,"maxPendingChunkedMessage":10,"autoAckOldestChunkedMessageOnQueueFull":false,"expireTimeOfIncompleteChunkedMessageMillis":60000,"cryptoFailureAction":"FAIL","properties":{},"readCompacted":false,"subscriptionInitialPosition":"Earliest","patternAutoDiscoveryPeriod":60,"regexSubscriptionMode":"PersistentOnly","deadLetterPolicy":null,"retryEnable":false,"autoUpdatePartitions":true,"autoUpdatePartitionsIntervalSeconds":60,"replicateSubscriptionState":false,"resetIncludeHead":false,"batchIndexAckEnabled":true,"ackReceiptEnabled":false,"poolMessages":true,"startPaused":false,"autoScaledReceiverQueueSizeEnabled":false,"topicConfigurations":[],"maxPendingChuckedMessage":10} {}
2026-08-23T15:17:57,444+0000 [pulsar-client-lookup-15-1] INFO  org.apache.pulsar.client.impl.ConsumerStatsRecorderImpl - Pulsar client config: {"serviceUrl":"pulsar://localhost:6650/","serviceUrlQuarantineInitDurationMs":60000,"serviceUrlQuarantineMaxDurationMs":86400000,"authPluginClassName":null,"authParams":null,"authParamMap":null,"originalPrincipal":null,"operationTimeoutMs":30000,"lookupTimeoutMs":30000,"statsIntervalSeconds":60,"numIoThreads":4,"numListenerThreads":4,"connectionsPerBroker":1,"connectionMaxIdleSeconds":60,"useTcpNoDelay":true,"useTls":false,"tlsKeyFilePath":"","tlsCertificateFilePath":"","tlsTrustCertsFilePath":"","tlsAllowInsecureConnection":false,"tlsHostnameVerificationEnable":false,"sslFactoryPlugin":"org.apache.pulsar.common.util.DefaultPulsarSslFactory","sslFactoryPluginParams":null,"concurrentLookupRequest":5000,"maxLookupRequest":50000,"maxLookupRedirects":20,"maxNumberOfRejectedRequestPerConnection":50,"keepAliveIntervalSeconds":30,"connectionTimeoutMs":10000,"requestTimeoutMs":60000,"readTimeoutMs":60000,"autoCertRefreshSeconds":300,"initialBackoffIntervalNanos":100000000,"maxBackoffIntervalNanos":60000000000,"enableBusyWait":false,"listenerName":null,"useKeyStoreTls":false,"sslProvider":null,"tlsKeyStoreType":"JKS","tlsKeyStorePath":"","tlsKeyStorePassword":"*****","tlsTrustStoreType":"JKS","tlsTrustStorePath":"","tlsTrustStorePassword":"*****","tlsCiphers":[],"tlsProtocols":[],"memoryLimitBytes":0,"proxyServiceUrl":null,"proxyProtocol":null,"enableTransaction":false,"dnsLookupBindAddress":null,"dnsLookupBindPort":0,"dnsServerAddresses":[],"socks5ProxyAddress":null,"socks5ProxyUsername":null,"socks5ProxyPassword":null,"description":null,"lookupProperties":{},"tracingEnabled":false,"openTelemetry":null} {}
2026-08-23T15:17:57,464+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/orders-cli][orders-cli-sub] Subscribing to topic on cnx [id: 0x60e478e9, L:/127.0.0.1:38930 - R:localhost/127.0.0.1:6650], consumerId 0 {}
2026-08-23T15:17:57,478+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/orders-cli][orders-cli-sub] Subscribed to topic on localhost/127.0.0.1:6650 -- consumer: 0 {}
----- got message -----
publishTime:[1787498273257], eventTime:[0], key:[null], properties:[], content:order-cli-1
----- got message -----
publishTime:[1787498273282], eventTime:[0], key:[null], properties:[], content:order-cli-2
----- got message -----
publishTime:[1787498273287], eventTime:[0], key:[null], properties:[], content:order-cli-3
2026-08-23T15:17:57,576+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://public/default/orders-cli] [orders-cli-sub] Closed consumer {}
2026-08-23T15:17:57,577+0000 [main] INFO  org.apache.pulsar.client.impl.PulsarClientImpl - Client closing. URL: pulsar://localhost:6650/ {}
2026-08-23T15:17:57,586+0000 [pulsar-client-io-1-3] INFO  org.apache.pulsar.client.impl.ClientCnx - [id: 0x60e478e9, L:/127.0.0.1:38930 ! R:localhost/127.0.0.1:6650] Disconnected {}
2026-08-23T15:17:59,602+0000 [main] INFO  org.apache.pulsar.client.cli.PulsarClientTool - 3 messages successfully consumed {}

## verify
[cli-tools] $ sh -c bin/pulsar-admin topics stats persistent://public/default/orders-cli && bin/pulsar-admin topics subscriptions persistent://public/default/orders-cli
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 144,
  "msgInCounter" : 3,
  "systemTopicBytesInCounter" : 0,
  "bytesOutCounter" : 144,
  "msgOutCounter" : 3,
  "bytesOutInternalCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 144,
  "backlogSize" : 0,
  "backlogQuotaLimitSize" : 10737418240,
  "backlogQuotaLimitTime" : -1,
  "oldestBacklogMessageAgeSeconds" : -1,
  "publishRateLimitedTimes" : 0,
  "earliestMsgPublishTimeInBacklogs" : 0,
  "offloadedStorageSize" : 0,
  "lastOffloadLedgerId" : 0,
  "lastOffloadSuccessTimeStamp" : 0,
  "lastOffloadFailureTimeStamp" : 0,
  "ongoingTxnCount" : 0,
  "abortedTxnCount" : 0,
  "committedTxnCount" : 0,
  "publishers" : [ ],
  "waitingPublishers" : 0,
  "subscriptions" : {
    "orders-cli-sub" : {
      "msgRateOut" : 0.0,
      "msgThroughputOut" : 0.0,
      "bytesOutCounter" : 144,
      "msgOutCounter" : 3,
      "msgRateRedeliver" : 0.0,
      "messageAckRate" : 0.0,
      "chunkedMessageRate" : 0.0,
      "msgBacklog" : 0,
      "backlogSize" : 0,
      "earliestMsgPublishTimeInBacklog" : 0,
      "msgBacklogNoDelayed" : 0,
      "blockedSubscriptionOnUnackedMsgs" : false,
      "msgDelayed" : 0,
      "msgInReplay" : 0,
      "unackedMessages" : 0,
      "type" : "Exclusive",
      "msgRateExpired" : 0.0,
      "msgExpired" : 0,
      "totalMsgExpired" : 0,
      "lastExpireTimestamp" : 0,
      "lastConsumedFlowTimestamp" : 1787498277479,
      "lastConsumedTimestamp" : 0,
      "lastAckedTimestamp" : 0,
      "lastMarkDeleteAdvancedTimestamp" : 1787498277580,
      "consumers" : [ ],
      "isDurable" : true,
      "isReplicated" : false,
      "allowOutOfOrderDelivery" : false,
      "consumersAfterMarkDeletePosition" : { },
      "drainingHashesCount" : 0,
      "drainingHashesClearedTotal" : 0,
      "drainingHashesUnackedMessages" : 0,
      "nonContiguousDeletedMessagesRanges" : 0,
      "nonContiguousDeletedMessagesRangesSerializedSize" : 0,
      "delayedMessageIndexSizeInBytes" : 0,
      "subscriptionProperties" : { },
      "filterProcessedMsgCount" : 0,
      "filterAcceptedMsgCount" : 0,
      "filterRejectedMsgCount" : 0,
      "filterRescheduledMsgCount" : 0,
      "dispatchThrottledMsgEventsBySubscriptionLimit" : 0,
      "dispatchThrottledBytesEventsBySubscriptionLimit" : 0,
      "dispatchThrottledMsgEventsByTopicLimit" : 0,
      "dispatchThrottledBytesEventsByTopicLimit" : 0,
      "dispatchThrottledMsgEventsByBrokerLimit" : 0,
      "dispatchThrottledBytesEventsByBrokerLimit" : 0,
      "replicated" : false,
      "durable" : true
    }
  },
  "replication" : { },
  "deduplicationStatus" : "Disabled",
  "nonContiguousDeletedMessagesRanges" : 0,
  "nonContiguousDeletedMessagesRangesSerializedSize" : 0,
  "delayedMessageIndexSizeInBytes" : 0,
  "compaction" : {
    "lastCompactionRemovedEventCount" : 0,
    "lastCompactionSucceedTimestamp" : 0,
    "lastCompactionFailedTimestamp" : 0,
    "lastCompactionDurationTimeInMills" : 0
  },
  "ownerBroker" : "localhost:8080",
  "topicCreationTimeStamp" : 1787498265476,
  "lastPublishTimeStamp" : 1787498273287
}
orders-cli-sub
status.out.txt
[cli-tools] $ bin/pulsar-admin brokers healthcheck
ok
[cli-tools] $ bin/pulsar-admin topics stats persistent://public/default/orders-cli
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 0,
  "msgInCounter" : 0,
  "systemTopicBytesInCounter" : 0,
  "bytesOutCounter" : 0,
  "msgOutCounter" : 0,
  "bytesOutInternalCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 0,
  "backlogSize" : 0,
  "backlogQuotaLimitSize" : 10737418240,
  "backlogQuotaLimitTime" : -1,
  "oldestBacklogMessageAgeSeconds" : -1,
  "publishRateLimitedTimes" : 0,
  "earliestMsgPublishTimeInBacklogs" : 0,
  "offloadedStorageSize" : 0,
  "lastOffloadLedgerId" : 0,
  "lastOffloadSuccessTimeStamp" : 0,
  "lastOffloadFailureTimeStamp" : 0,
  "ongoingTxnCount" : 0,
  "abortedTxnCount" : 0,
  "committedTxnCount" : 0,
  "publishers" : [ ],
  "waitingPublishers" : 0,
  "subscriptions" : { },
  "replication" : { },
  "deduplicationStatus" : "Disabled",
  "nonContiguousDeletedMessagesRanges" : 0,
  "nonContiguousDeletedMessagesRangesSerializedSize" : 0,
  "delayedMessageIndexSizeInBytes" : 0,
  "compaction" : {
    "lastCompactionRemovedEventCount" : 0,
    "lastCompactionSucceedTimestamp" : 0,
    "lastCompactionFailedTimestamp" : 0,
    "lastCompactionDurationTimeInMills" : 0
  },
  "ownerBroker" : "localhost:8080",
  "topicCreationTimeStamp" : 1787498265476,
  "lastPublishTimeStamp" : 0
}
verify.out.txt
[cli-tools] $ sh -c bin/pulsar-admin topics stats persistent://public/default/orders-cli && bin/pulsar-admin topics subscriptions persistent://public/default/orders-cli
{
  "msgRateIn" : 0.0,
  "msgThroughputIn" : 0.0,
  "msgRateOut" : 0.0,
  "msgThroughputOut" : 0.0,
  "bytesInCounter" : 144,
  "msgInCounter" : 3,
  "systemTopicBytesInCounter" : 0,
  "bytesOutCounter" : 144,
  "msgOutCounter" : 3,
  "bytesOutInternalCounter" : 0,
  "averageMsgSize" : 0.0,
  "msgChunkPublished" : false,
  "storageSize" : 144,
  "backlogSize" : 0,
  "backlogQuotaLimitSize" : 10737418240,
  "backlogQuotaLimitTime" : -1,
  "oldestBacklogMessageAgeSeconds" : -1,
  "publishRateLimitedTimes" : 0,
  "earliestMsgPublishTimeInBacklogs" : 0,
  "offloadedStorageSize" : 0,
  "lastOffloadLedgerId" : 0,
  "lastOffloadSuccessTimeStamp" : 0,
  "lastOffloadFailureTimeStamp" : 0,
  "ongoingTxnCount" : 0,
  "abortedTxnCount" : 0,
  "committedTxnCount" : 0,
  "publishers" : [ ],
  "waitingPublishers" : 0,
  "subscriptions" : {
    "orders-cli-sub" : {
      "msgRateOut" : 0.0,
      "msgThroughputOut" : 0.0,
      "bytesOutCounter" : 144,
      "msgOutCounter" : 3,
      "msgRateRedeliver" : 0.0,
      "messageAckRate" : 0.0,
      "chunkedMessageRate" : 0.0,
      "msgBacklog" : 0,
      "backlogSize" : 0,
      "earliestMsgPublishTimeInBacklog" : 0,
      "msgBacklogNoDelayed" : 0,
      "blockedSubscriptionOnUnackedMsgs" : false,
      "msgDelayed" : 0,
      "msgInReplay" : 0,
      "unackedMessages" : 0,
      "type" : "Exclusive",
      "msgRateExpired" : 0.0,
      "msgExpired" : 0,
      "totalMsgExpired" : 0,
      "lastExpireTimestamp" : 0,
      "lastConsumedFlowTimestamp" : 1787498277479,
      "lastConsumedTimestamp" : 0,
      "lastAckedTimestamp" : 0,
      "lastMarkDeleteAdvancedTimestamp" : 1787498277580,
      "consumers" : [ ],
      "isDurable" : true,
      "isReplicated" : false,
      "allowOutOfOrderDelivery" : false,
      "consumersAfterMarkDeletePosition" : { },
      "drainingHashesCount" : 0,
      "drainingHashesClearedTotal" : 0,
      "drainingHashesUnackedMessages" : 0,
      "nonContiguousDeletedMessagesRanges" : 0,
      "nonContiguousDeletedMessagesRangesSerializedSize" : 0,
      "delayedMessageIndexSizeInBytes" : 0,
      "subscriptionProperties" : { },
      "filterProcessedMsgCount" : 0,
      "filterAcceptedMsgCount" : 0,
      "filterRejectedMsgCount" : 0,
      "filterRescheduledMsgCount" : 0,
      "dispatchThrottledMsgEventsBySubscriptionLimit" : 0,
      "dispatchThrottledBytesEventsBySubscriptionLimit" : 0,
      "dispatchThrottledMsgEventsByTopicLimit" : 0,
      "dispatchThrottledBytesEventsByTopicLimit" : 0,
      "dispatchThrottledMsgEventsByBrokerLimit" : 0,
      "dispatchThrottledBytesEventsByBrokerLimit" : 0,
      "replicated" : false,
      "durable" : true
    }
  },
  "replication" : { },
  "deduplicationStatus" : "Disabled",
  "nonContiguousDeletedMessagesRanges" : 0,
  "nonContiguousDeletedMessagesRangesSerializedSize" : 0,
  "delayedMessageIndexSizeInBytes" : 0,
  "compaction" : {
    "lastCompactionRemovedEventCount" : 0,
    "lastCompactionSucceedTimestamp" : 0,
    "lastCompactionFailedTimestamp" : 0,
    "lastCompactionDurationTimeInMills" : 0
  },
  "ownerBroker" : "localhost:8080",
  "topicCreationTimeStamp" : 1787498265476,
  "lastPublishTimeStamp" : 1787498273287
}
orders-cli-sub

官方资料 ​

以统一实验验证消息系统语义边界