public void destroyQueue(final SimpleString queueName, final ServerSession session) throws Exception
{
addressSettingsRepository.clearCache();
Binding binding = postOffice.getBinding(queueName);
if (binding == null)
{
throw new HornetQException(HornetQException.QUEUE_DOES_NOT_EXIST, "No such queue " + queueName);
}
Queue queue = (Queue)binding.getBindable();
if (queue.getPageSubscription() != null)
{
queue.getPageSubscription().close();
}
if (queue.getConsumerCount() != 0)
{
throw new HornetQException(HornetQException.ILLEGAL_STATE, "Cannot delete queue " + queue.getName() +
" on binding " +
queueName +
" - it has consumers = " +
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.deleteAllReferences();