From users-return-7715-apmail-activemq-users-archive=activemq.apache.org@activemq.apache.org Fri Mar 02 16:01:32 2007 Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 60390 invoked from network); 2 Mar 2007 16:01:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Mar 2007 16:01:31 -0000 Received: (qmail 5966 invoked by uid 500); 2 Mar 2007 16:01:39 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 5837 invoked by uid 500); 2 Mar 2007 16:01:39 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 5827 invoked by uid 99); 2 Mar 2007 16:01:39 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Mar 2007 08:01:39 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of kelly.a.campbell@gmail.com designates 64.233.162.229 as permitted sender) Received: from [64.233.162.229] (HELO nz-out-0506.google.com) (64.233.162.229) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Mar 2007 08:01:27 -0800 Received: by nz-out-0506.google.com with SMTP id f1so867745nzc for ; Fri, 02 Mar 2007 08:01:07 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=khSTL7viN42jhalj6cbuKfwZcXnyNhy6ptaaqmGKVk5hjeCkz1OXfVTdzIJUTlDARrCc6pwukExk9wA1ZNvjeovztKs9JotlekScioW9i1QKBoVhXXYdxOjL6p4j1BmZBSovMRiZcUPO6NzebZX1OGjwiXMB2yuA71QnCYJomOk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NW/9P6h2tmHHHWQ18UxYVi8v3bvR9TNYHXl9MsrGcPrbLdx7Tm2FbO3gOKZbMAW791zZXgpNG0DQE0PWrgDe6tNrEKXQ+igG9zvHD2gO7UMqY0w2R7f6sMWoWkvN8+sIJVaNqVDGWFp63BTAE/M46kPAW/B/mIE28LKYmvJwddg= Received: by 10.114.151.13 with SMTP id y13mr281670wad.1172851266179; Fri, 02 Mar 2007 08:01:06 -0800 (PST) Received: by 10.114.59.2 with HTTP; Fri, 2 Mar 2007 08:01:06 -0800 (PST) Message-ID: <653849d10703020801o7ca87acn894767951c1c0757@mail.gmail.com> Date: Fri, 2 Mar 2007 11:01:06 -0500 From: "Kelly Campbell" To: users@activemq.apache.org Subject: Re: Remove all messages from a queue In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4354353.post@talk.nabble.com> <446A046C.8070303@daxtechnologies.com> <446B38FE.9050505@daxtechnologies.com> <446B5AB3.5090000@daxtechnologies.com> <446B7F01.8010502@daxtechnologies.com> <653849d10703011413q6bcf8919x1740491958aea094@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org One problem with Rob's method of initialization is you have to re-initialize the broker for each unit test which I'd rather not do for performance reasons. The problem with the recommended approach James mentioned in the docs (turning persistence off), is what about when you specifically want to test the persistence functionality and how your application uses it? I'm trying to use the local jmx server to do the purge, but it gets an InstanceNotFoundException for the MX bean. (code below): MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer(); Queue queue = createQueue(queueName); // open a connection, session, create the queue ObjectName objName = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=" + queueName); jmxServer.invoke(objName, "purge", null, null); The order of getting the MBeanServer vs. createQueue doesn't seem to matter. I get the same exception in both cases. On 3/2/07, Rob Davies wrote: > for unit tests - we often set the deleteAllMessagesOnStartup flag on > the broker > > For your case where you are using the vm://transport, create the > broker separetly in your setUp() - and set the > deleteAllMessageOnStartup property on the broker before calling start > () or setting a transport connector (for vm:// you won't need to > explicitly do this). > > cheers, > > > Rob Davies > http://rajdavies.blogspot.com/ > > > > On 1 Mar 2007, at 22:13, Kelly Campbell wrote: > > > I'm trying to figure out how to do this same thing in the current > > codebase (4.1/4.2). Basically I just want to purge all queues at the > > beginning of a unit test to ensure a clean start. I have a local vm:// > > broker and would prefer not to go through JMX to do this. > > > > Thanks, > > Kelly > > > > On 5/17/06, Hiram Chirino wrote: > >> Correct. > >> > >> On 5/17/06, Adrian Tarau wrote: > >> > Thanks. I presume this purge will remove all the messages from the > >> > persistance, right? not only memory... > >> > > >> > Hiram Chirino wrote: > >> > > Yes. That should be a map of ActiveMQDestination to > >> > > o.a.a.b.r.Destination objects. > >> > > You should be able to do something like ((o.a.a.b.r.Queue) > >> > > destination).purge(); > >> > > > >> > > On 5/17/06, Adrian Tarau wrote: > >> > >> > >> > >> BrokerServer.getBroker().getDestinationMap() ? > >> > >> > >> > >> Hiram Chirino wrote: > >> > >> > Hi Adrian, > >> > >> > > >> > >> > If you get a hold of the BrokerServer it should be possible > >> navigate > >> > >> > the object tree and be able to get a Queue object and ask > >> it to delete > >> > >> > it's messages. > >> > >> > > >> > >> > > >> > >> > On 5/17/06, Adrian Tarau wrote: > >> > >> >> James? Anybody? Help? :) > >> > >> >> > >> > >> >> Adrian Tarau wrote: > >> > >> >> > James? Any suggestions how to clear a queue with > >> activemq API > >> > >> without > >> > >> >> > JMX? Thanks. > >> > >> >> > > >> > >> >> > Adrian Tarau wrote: > >> > >> >> >> I know the utility of JMX, I use it :) But right now I > >> don't > >> > >> want to > >> > >> >> >> activate JMX. I saw that ActiveMQ use MX4J 2.1.1(why > >> don't use > >> > >> >> >> 3.0.1?) and I have already in my application MX4J 3.0.1 > >> > >> libraries and > >> > >> >> >> I remember I used 3.0.1 with a project that need 2.1.x > >> and was not > >> > >> >> >> working. > >> > >> >> >> > >> > >> >> >> And of course I cannot have two version of MX4J in my > >> application. > >> > >> >> >> > >> > >> >> >> James Strachan wrote: > >> > >> >> >>> On 5/15/06, Adrian Tarau wrote: > >> > >> >> >>>> Since I use embedded JMS is not necessary to activate > >> also JMX, > >> > >> >> >>> > >> > >> >> >>> JMX is extremely useful. e.g. in JConsole you can > >> watch all of > >> > >> the > >> > >> >> >>> mbeans in an application (the garbage collector, > >> number of > >> > >> threads, > >> > >> >> >>> amount of memory free together wtih the ActiveMQ > >> mbeans such > >> > >> as all > >> > >> >> >>> the destinations & consumers and queue depths etc > >> > >> >> >>> > >> > >> >> >>> > >> > >> >> >>>> and JMX > >> > >> >> >>>> MBeans already use those parts to interrogate for > >> values outside > >> > >> >> >>>> the JMS > >> > >> >> >>>> standard. Why not to be accessible with Java code and > >> only JMX? > >> > >> >> >>> > >> > >> >> >>> Everything is accessible via Java code and JMX; the > >> reason I > >> > >> suggest > >> > >> >> >>> JMX is that > >> > >> >> >>> > >> > >> >> >>> (i) it can work with remote brokers too > >> > >> >> >>> (ii) it works great in JConsole - so its really easy > >> to look > >> > >> at the > >> > >> >> >>> mbeans whenever you like (rather than having to write > >> Java code) > >> > >> >> >>> > >> > >> >> >> > >> > >> >> > > >> > >> >> > >> > >> >> > >> > >> > > >> > >> > > >> > >> > >> > >> > >> > > > >> > > > >> > > >> > > >> > >> > >> -- > >> Regards, > >> Hiram > >> > > > > > > >