VirtualHost virtualHost = getVirtualHost(session);
DurableConfigurationStore store = virtualHost.getDurableConfigurationStore();
String queueName = method.getQueue();
AMQQueue queue;
QueueRegistry queueRegistry = getQueueRegistry(session);
//TODO: do we need to check that the queue already exists with exactly the same "configuration"?
synchronized (queueRegistry)
{
if (((queue = queueRegistry.getQueue(queueName)) == null))
{
if (method.getPassive())
{
String description = "Queue: " + queueName + " not found on VirtualHost(" + virtualHost + ").";
ExecutionErrorCode errorCode = ExecutionErrorCode.NOT_FOUND;
exception(session, method, errorCode, description);
return;
}
else
{
try
{
queue = createQueue(queueName, method, virtualHost, (ServerSession)session);
if(method.getExclusive())
{
queue.setExclusive(true);
}
else if(method.getAutoDelete())
{
queue.setDeleteOnNoConsumers(true);
}
final String alternateExchangeName = method.getAlternateExchange();
if(alternateExchangeName != null && alternateExchangeName.length() != 0)
{
Exchange alternate = getExchange(session, alternateExchangeName);
queue.setAlternateExchange(alternate);
}
if(method.hasArguments() && method.getArguments() != null)
{
if(method.getArguments().containsKey("no-local"))
{
Object no_local = method.getArguments().get("no-local");
if(no_local instanceof Boolean && ((Boolean)no_local))
{
queue.setNoLocal(true);
}
}
}
if (queue.isDurable() && !queue.isAutoDelete())
{
if(method.hasArguments() && method.getArguments() != null)
{
Map<String,Object> args = method.getArguments();
FieldTable ftArgs = new FieldTable();
for(Map.Entry<String, Object> entry : args.entrySet())
{
ftArgs.put(new AMQShortString(entry.getKey()), entry.getValue());
}
store.createQueue(queue, ftArgs);
}
else
{
store.createQueue(queue);
}
}
queueRegistry.registerQueue(queue);
boolean autoRegister = ApplicationRegistry.getInstance().getConfiguration().getQueueAutoRegister();
if (autoRegister)
{