On Tue, Aug 11, 2009 at 1:40 PM, centis<centis_b...@hotmail.com> wrote: > > I am trying to find an example of purging a Queue from Java. Can someone > point me to someting besides, "Using JMX..." :) I just need a way to clear > out the existing queues before my regression tests run.
Oddly, the solution is to use JMX; just programatically instead of via Jconsole. Here's an example: // The ActiveMQ JMX domain String amqDomain = "org.apache.activemq"; // The parameters for an ObjectName Hashtable<String, String> params = new Hashtable<String, String>(); params.put("Type", "Queue"); params.put("BrokerName", brokerName); params.put("Destination", queueName); // Create an ObjectName ObjectName queueObjectName = ObjectName.getInstance(amqDomain, params); // Create a proxy to the QueueViewMBean QueueViewMBean queueProxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueObjectName, QueueViewMBean.class, true); // Purge the queue queueProxy.purge(); Bruce -- perl -e 'print unpack("u30","D0G)u8...@4vyy9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*" );' ActiveMQ in Action: http://bit.ly/2je6cQ Blog: http://bruceblog.org/ Twitter: http://twitter.com/brucesnyder