Search code examples
apache-pulsar

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


I have a Spark application that is leaving behind durable subscriptions to Pulsar and makes it look like my backlog is increasing on the topic when all consumers are actually up to date. Is there a way to expire or delete subscriptions that are no longer being used (i.e. not attached to a consumer) and leave other subscriptions (some of which may be idle) alone?


Solution

  • You can configure Pulsar to expire subscriptions that have no consumers connected using the subscriptionExpirationTimeMinutes setting in the broker.conf globally or at the namespace level using the following CLI command:

    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
    

    Setting this to a non-zero value enables the feature.