activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <>
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<> 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)
QueueViewMBean.class, true);

// Purge the queue

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:

View raw message