HornetQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\"");
try
{
JMSServerConfigParserImpl parser = new JMSServerConfigParserImpl();
JMSQueueConfiguration queue = parser.parseQueueConfiguration(document.getDocumentElement());
HornetQQueue hqQueue = HornetQDestination.createQueue(queue.getName());
String queueName = hqQueue.getAddress();
ClientSession session = manager.getSessionFactory().createSession(false, false, false);
try
{
ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName));
if (!query.isExists())
{
if (queue.getSelector() != null)
{
session.createQueue(queueName, queueName, queue.getSelector(), queue.isDurable());
}
else
{
session.createQueue(queueName, queueName, queue.isDurable());
}
}
else
{
throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build());
}
}
finally
{
try
{
session.close();
}
catch (Exception ignored)
{
}
}
if (queue.getBindings() != null && queue.getBindings().length > 0 && manager.getRegistry() != null)
{
for (String binding : queue.getBindings())
{
manager.getRegistry().bind(binding, hqQueue);
}
}
URI uri = uriInfo.getRequestUriBuilder().path(queueName).build();