TheCycoONE
TheCycoONE

Reputation: 186

Purge all messages in ActiveMQ Artemis

We have several ActiveMQ Artemis 2.17.0 clusters setup to replicate between data centres with mirroring.

Our previous failover had been an emergency, and it's likely the state had fallen out of sync. When we next performed our scheduled failover tests weeks-old messages were sent to the consumers. I know that mirroring is asynchronous so it is expected that synchronization may not be 100% all the time. However, these messages were not within the time frame of synchronization delays. It is worth noting that we've had several events which I expect might throw mirroring off. We had hit the NFS split brain issue as well as the past emergency fail over

As such, we are looking for a way to purge (or sync) all messages on the standby server after we know that there have been problems with the mirroring to prevent a similar scenario from happening. There are over 5,000 queues, so preferably the operation doesn't need to be run on a queue by queue basis.

Is there any way to accomplish this, either in ActiveMQ Artemis 2.17.0 or a later version?

Upvotes: 1

Views: 2225

Answers (1)

Justin Bertram
Justin Bertram

Reputation: 34988

There's no programmatic way to simply delete all the data from every queue on the broker. However, you can combine a few management operations (e.g. in a script) to get the same result. You can use the getQueueNames method to get the name of every queue and then pass those names to the destroyQueue(String) method.

However, the simplest way to clear all the data would probably be to simply stop the broker, clear the data directory, and then restart the broker.

Upvotes: 2

Related Questions