CompositeConfiguration queueConfiguration = new CompositeConfiguration();
queueConfiguration.addConfiguration(configuration.subset("queues.queue."+ queueNameString));
queueConfiguration.addConfiguration(configuration.subset("queues"));
QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
MessageStore messageStore = virtualHost.getMessageStore();
ExchangeRegistry exchangeRegistry = virtualHost.getExchangeRegistry();
AMQShortString queueName = new AMQShortString(queueNameString);
AMQQueue queue;
synchronized (queueRegistry)
{
queue = queueRegistry.getQueue(queueName);
if (queue == null)
{
_logger.info("Creating queue '" + queueName + "' on virtual host " + virtualHost.getName());
boolean durable = queueConfiguration.getBoolean("durable" ,false);
boolean autodelete = queueConfiguration.getBoolean("autodelete", false);
String owner = queueConfiguration.getString("owner", null);
FieldTable arguments = null;
Integer priorities = queueConfiguration.getInteger("priorities", null);
if(priorities != null && priorities.intValue() > 1)
{
if(arguments == null)
{
arguments = new FieldTable();
}
arguments.put(new AMQShortString("x-qpid-priorities"), priorities);
}
queue = AMQQueueFactory.createAMQQueueImpl(queueName,
durable,
owner == null ? null : new AMQShortString(owner) /* These queues will have no owner */,
autodelete /* Therefore autodelete makes no sence */,
virtualHost,
arguments,
queueConfiguration);
if (queue.isDurable())
{
messageStore.createQueue(queue);
}
queueRegistry.registerQueue(queue);
}
else
{
_logger.info("Queue '" + queueNameString + "' already exists on virtual host "+virtualHost.getName()+", not creating.");
}