public void destroyQueue(final SimpleString queueName, final ServerSession session, final boolean checkConsumerCount) throws Exception
{
addressSettingsRepository.clearCache();
Binding binding = postOffice.getBinding(queueName);
if (binding == null)
{
throw HornetQMessageBundle.BUNDLE.noSuchQueue(queueName);
}
Queue queue = (Queue)binding.getBindable();
// This check is only valid if checkConsumerCount == true
if (checkConsumerCount && queue.getConsumerCount() != 0)
{
throw HornetQMessageBundle.BUNDLE.cannotDeleteQueue(queue.getName(), queueName, binding.getClass().getName());
}
if (session != null)
{
if (queue.isDurable())
{
// make sure the user has privileges to delete this queue
securityStore.check(binding.getAddress(), CheckType.DELETE_DURABLE_QUEUE, session);
}
else
{
securityStore.check(binding.getAddress(), CheckType.DELETE_NON_DURABLE_QUEUE, session);
}
}
queue.deleteQueue();
}