public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<QueueDeclareBody> evt) throws AMQException
{
AMQProtocolSession session = stateManager.getProtocolSession();
VirtualHost virtualHost = session.getVirtualHost();
ExchangeRegistry exchangeRegistry = virtualHost.getExchangeRegistry();
QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
MessageStore store = virtualHost.getMessageStore();
QueueDeclareBody body = evt.getMethod();
// if we aren't given a queue name, we create one which we return to the client
if (body.queue == null)
{
body.queue = createName();
}
AMQQueue queue;
//TODO: do we need to check that the queue already exists with exactly the same "configuration"?
synchronized (queueRegistry)
{
if (((queue = queueRegistry.getQueue(body.queue)) == null))
{
if(body.queue != null)
{
body.queue = body.queue.intern();
}
if (body.passive)
{
String msg = "Queue: " + body.queue + " not found on VirtualHost(" + virtualHost + ").";
throw body.getChannelException(AMQConstant.NOT_FOUND, msg);
}
else
{
queue = createQueue(body, virtualHost, session);
if (queue.isDurable() && !queue.isAutoDelete())
{
store.createQueue(queue);
}
queueRegistry.registerQueue(queue);
if (autoRegister)
{
Exchange defaultExchange = exchangeRegistry.getDefaultExchange();
queue.bind(body.queue, null, defaultExchange);