Hello James, thank you very much for your reply. Per your questions about why would we like to delete queues, the answer is that we do not re-use queues for an extra security measure, we don't re-use queues having the same name. Rather we create a new queue for the Client each time it connects. In this case we are simulating a failure and so the queues must be removed to avoid having them lie around. When we are monitoring the AMQ we also don't want to see old un-used queues, even if they don't take up much resources. Note there will be however thousands of clients which would equate to thousands of unused queues if we didn't delete them.
So, currently the solution I think of is to add another method to AbstractRegion class, called removeDestinations(List<String> destsToRemove) that would remove destinations which match the provided names in one single acquire-release-destinations-mutex step, and thus to avoid waiting for destinationsMutex during one by one deletion of destinations. Does the above make sense? Is there any better solution? Thank you in advance, Andrew. James.Strachan wrote: > > On 5/12/07, astepanenko <[EMAIL PROTECTED]> 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? > > -- > James > ------- > http://macstrac.blogspot.com/ > > -- View this message in context: http://www.nabble.com/Correct-way-to-removeDestinations%28%29-tf3732843s2354.html#a10610678 Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
