Wheezil
Wheezil

Reputation: 3462

enumerating and deleting activemq queues using JMS client

I desire to programatically purge all queues, either as an administrative function or during dev/test to get a clean system.

Following inline examples, I've written code like:

ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
ActiveMQConnection connection = (ActiveMQConnection)connectionFactory.createConnection();
DestinationSource destinationSource = connection.getDestinationSource();
for (ActiveMQQueue queue : destinationSource.getQueues()) {
    connection.destroyDestination(queue);
}

However, getQueues() always returns an empty set, even though there are queues visible in the web console. Looking at the source code, it appears that the queues list is only populated by listening for queue-create advisory topic messages, so any queues that exist at the time this code is run are not listed.

This would seem to contradict the ActiveMQ docs where it says "As of 5.1.0 you can use the new DestinationSource on an ActiveMQConnection to access the available queues"

Am I doing something wrong? Is there a better interface to enumerating and purging queues?

I am using ActiveMQ 5.15.12

This is also the topic of a bug report I submitted

Upvotes: 0

Views: 53

Answers (1)

Tim Bish
Tim Bish

Reputation: 18376

The best way to manage Queues would be via the JMX Mbeans from the broker itself that expose APIs for enumerating the Queues and for purging, deleting etc which a manager would want.

Another option is to use the Jalokia Rest API which is a nice layer over the JMX MBeans

There's some good docs for managing ActiveMQ via JMX just a quick Google search away.

Upvotes: 1

Related Questions