activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astepanenko <>
Subject Correct way to removeDestinations()
Date Sat, 12 May 2007 19:03:33 GMT

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. 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:


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:

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? Should I
iterate over the queue subscribers and try to force them to close and then
remove the destination? I also do not get JMSException("Destination still
has an active subscription:" ...) since the Broker waits for timeout.

I also noticed that there is no control over timeout value from the user
perspective, since getAdminView().removeQueue() doesn't let you to specify

Any help is much appreciated.

Thank you in advance,
View this message in context:
Sent from the ActiveMQ - Dev mailing list archive at

View raw message