Search code examples
message-queueapache-pulsar

How to avoid the automatic deleting of inactive topics in Apache Pulsar


I have an application that produces messages to Pulsar under a specific topic and shut down the application when it's finished; at the same time, no consumer exists to read this topic.

After a while, when I create a consumer and want to read the written data out, I found all data are lost since the topic I've written been deleted by Pulsar.

How can I disable the auto-deletion of inactive topics in Pulsar?


Solution

  • Generally, there are two ways to achieve this.

    • Firstly, retention policies keep the data for at least X hours (until Y GBs), you could set it via pulsar-admin to infinite at the namespace level.
      pulsar-admin namespaces set-retention my-tenant/my-ns \
      --size 1T \
      --time -1
    
    • Secondly, manually set brokerDeleteInactiveTopicsEnabled=false in conf/broker.conf could disable the deletion of inactive topics as well.

    It's recommended to set the above two settings simultaneously for proper control.