activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: Correct way to removeDestinations()
Date Mon, 14 May 2007 14:57:17 GMT
On 5/12/07, astepanenko <> wrote:
> Dear Developers,
> I my project I need to create and remove destinations (Queues) for
> connecting/disconnecting clients frequently. After reading a bit on JMS
> topics I got a feeling that in general dynamic creation of queues/topics is
> not encouraged.

Not at all - be totally dynamic if you like

> But I need to do that anyway.
> Sometimes I also need to remove all queues at a Broker instance except of my
> CONTROL_QUEUE. So, in DELETE_QUEUES onMessage() handler I do:
> ObjectName[] queues = brokerService.getAdminView().getQueues();
> then for each queue received I check if it's not a CONTROL_QUEUE and do:
> brokerService.getAdminView().removeQueue(qName);

Why do you need to delete a queue? FWIW purging a queue is more usual

> The problem is that after the above deletion I create new queues at the
> Broker but it appears that DELETE_QUEUES message processing still not
> finished at the time I call jmsSession.createQueue() and as a result I get
> my newly created queues deleted too.
> Both DELETE_QUEUES message is sent and new queues are created from the same
> remote client, so in the logs two operations appear one after another with
> smth like 4 seconds interval. But at the broker side, we noticed that each
> queue deletion takes too much time, smth like 1 second per each queue.
> Later in the sources of BrokerView.removeQueue(String name) I found:
> broker.removeDestination(getConnectionContext(broker.getContextBroker()),
> new ActiveMQQueue(name), 1000);
> The last parameter is timeout in milliseconds and it explained why each
> queue deletion takes up-to 1 second.
> So, finally the call to removeQueue() ends up in
> AbstractRegion.removeDestination(...) which actually synchronizes on
> destinationsMutex and then removes the destination.
> Taking the above into account, what would be the correct and efficient (not
> waiting for timeout) way to remove queues (and topics) from Broker?

I still don't get why you really care about removing a queue; surely
just purging it would do the trick?


View raw message