views:

281

answers:

2

Fellow StackOverflowers, is there a way for me to remove a queue or a topic in ActiveMQ programatically? I am using ActiveMQ's standard persistency, and my application requires that, on startup, all new queues be dynamically re-created (unless there are messages stored in the queue, in which case, the queue should remain to exist).

I am also creating all queues programatically through sessions. Is there an equivalent to that procedure, only to delete a queue? Querying and iterating through the existing queues would also be useful, but i haven't found a way to do that yet.

Please help an ActiveMQ noob! =)

A: 

While there's not a lot of concrete examples, there's some documentation about it here : http://activemq.apache.org/how-do-i-purge-a-queue.html

nos
Thanks nos, i'll take a look at the BrokerViewMBean interface later on and see what i can do with it. I'll let you know if it works.
Eduardo Z.
+1  A: 

To remove a destination from ActiveMQ programmatically, you will need to do so via JMX using the removeTopic and removeQueue methods on the broker MBean (org.apache.activemq:BrokerName=localhost,Type=Broker). I have posted some example code to demonstrate this, including the use of the removeTopic method, over on Gist:

http://gist.github.com/439668

Hope that helps.

Bruce

bsnyder