public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<QueueDeleteBody> evt) throws AMQException
{
AMQProtocolSession session = stateManager.getProtocolSession();
VirtualHost virtualHost = session.getVirtualHost();
QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
MessageStore store = virtualHost.getMessageStore();
QueueDeleteBody body = evt.getMethod();
AMQQueue queue;
if (body.queue == null)
{
AMQChannel channel = session.getChannel(evt.getChannelId());
if (channel == null)
{
throw body.getChannelNotFoundException(evt.getChannelId());
}
//get the default queue on the channel:
queue = channel.getDefaultQueue();
}
else
{
queue = queueRegistry.getQueue(body.queue);
}
if (queue == null)
{
if (_failIfNotFound)
{
throw body.getChannelException(AMQConstant.NOT_FOUND, "Queue " + body.queue + " does not exist.");
}
}
else
{
if (body.ifEmpty && !queue.isEmpty())
{
throw body.getChannelException(AMQConstant.IN_USE, "Queue: " + body.queue + " is not empty.");
}
else if (body.ifUnused && !queue.isUnused())
{
// TODO - Error code
throw body.getChannelException(AMQConstant.IN_USE, "Queue: " + body.queue + " is still used.");
}
else
{
int purged = queue.delete(body.ifUnused, body.ifEmpty);
if (queue.isDurable())
{
store.removeQueue(queue.getName());
}
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
// Be aware of possible changes to parameter order as versions change.