ActiveMQ - uninstall programs programmatically

Fellow StackOverflowers, is there a way so that I can programmatically delete a queue or topic in ActiveMQ? I use the standard ActiveMQ constant, and my application requires that all new queues be dynamically recreated at startup (if there are no messages in the queue, then the queue must remain available).

I also create all queues programmatically through sessions. Is there an equivalent to this procedure, only to remove the queue? Querying and retrying through existing queues would also be helpful, but I have not yet found a way to do this.

+6
queue persistence activemq
source share
4 answers

You can also Delete recipients that are inactive for a period of time. Available with Active MQ 5.4

Alternatively, if you use the built-in ActiveMQ, you can use the API to remove recipients: Region.removeDestination

+6
source share

To remove a destination from ActiveMQ programmatically, you will need to do this through JMX using the removeTopic and removeQueue on the MBean broker ( org.apache.activemq:BrokerName=localhost,Type=Broker ). I demonstrated some sample code to demonstrate this, including using the removeTopic method, over a Gist:

http://gist.github.com/439668

Hope this helps.

Bruce

+4
source share

If you are using spring JmsTemplate, you can do it like this:

 Connection cn = getJmsTemplate().getConnectionFactory().createConnection(); ActiveMQDestination destination = ActiveMQDestination.createDestination(queueName, ActiveMQDestination.QUEUE_TYPE); if(cn instanceof PooledConnection){ ((PooledConnection)cn).getConnection().destroyDestination(destination ); } 
+2
source share

While there are no specific examples, there is documentation about this: http://activemq.apache.org/how-do-i-purge-a-queue.html

0
source share

All Articles