activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <bruce.sny...@gmail.com>
Subject Re: Programmatically purge() a queue
Date Wed, 12 Aug 2009 01:34:21 GMT
On Tue, Aug 11, 2009 at 1:40 PM, centis<centis_biks@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)U8V4\@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

Mime
View raw message