Search code examples
apache-pulsar

What is the most efficient way to delete/expire all messages in a Apache Pulsar topic?


I'm trying to figure out what would be the best way to remove all the messages from a Pulsar topic (either logically or physically), so that they are no longer consumable by subscriptions?

I know we can simply do $ pulsar-admin persistent delete persistent://tenant/namespace/topic.

But, this solution has some drawbacks: it removes the topic completely (so we have to recreate it later) then there should be no active client connected to it (i.e: subscriptions or producers).

Alternatively is there a way to programmatically make all messages between two MessageId unavailable to the subscriptions ?

Thanks


Solution

  • There are a couple of options you can choose from.