VirtualHost virtualHost = session.getVirtualHost();
QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
AMQChannel channel = session.getChannel(evt.getChannelId());
QueuePurgeBody body = evt.getMethod();
AMQQueue queue;
if(body.queue == null)
{
if (channel == null)
{
throw body.getChannelNotFoundException(evt.getChannelId());
}
//get the default queue on the channel:
queue = channel.getDefaultQueue();
if(queue == null)
{
if(_failIfNotFound)
{
throw body.getConnectionException(AMQConstant.NOT_ALLOWED,"No queue specified.");
}
}
}
else
{
queue = queueRegistry.getQueue(body.queue);
}
if(queue == null)
{
if(_failIfNotFound)
{
throw body.getChannelException(AMQConstant.NOT_FOUND, "Queue " + body.queue + " does not exist.");
}
}
else
{
long purged = queue.clearQueue(channel.getStoreContext());