在 Pulsar 中,有没有一种方法可以清理没有附加消费者的旧持久订阅?

In Pulsar is there a way to clean-up old durable subscriptions that do not have a consumer attached?

我有一个 Spark 应用程序,它留下了对 Pulsar 的持久订阅,并且当所有消费者实际上都是最新的时,看起来我在该主题上的积压工作正在增加。有没有办法使不再使用的订阅过期或删除(即未附加到消费者)并单独留下其他订阅(其中一些可能闲置)?

您可以使用 broker.conf 中的 subscriptionExpirationTimeMinutes 设置全局或在命名空间级别使用以下 CLI 命令将 Pulsar 配置为使没有消费者连接的订阅过期:

bin/pulsar-admin namespaces set-subscription-expiration-time

Set subscription expiration time for a namespace
Usage: set-subscription-expiration-time [options] tenant/namespace
  Options:
  * -t, --time
      Subscription expiration time in minutes
      Default: 0

将此设置为非零值可启用该功能。