use of org.apache.activemq.artemis.jms.client.ActiveMQQueue in project activemq-artemis by apache.
the class QueueDestinationsResource method createJmsQueue.
@POST
@Consumes("application/activemq.jms.queue+xml")
public Response createJmsQueue(@Context UriInfo uriInfo, Document document) {
ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\"");
try {
JMSQueueConfiguration queue = FileJMSConfiguration.parseQueueConfiguration(document.getDocumentElement());
ActiveMQQueue activeMQQueue = ActiveMQDestination.createQueue(queue.getName());
String queueName = activeMQQueue.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) {
}
}
URI uri = uriInfo.getRequestUriBuilder().path(queueName).build();
return Response.created(uri).build();
} catch (Exception e) {
if (e instanceof WebApplicationException)
throw (WebApplicationException) e;
throw new WebApplicationException(e, Response.serverError().type("text/plain").entity("Failed to create queue.").build());
}
}
use of org.apache.activemq.artemis.jms.client.ActiveMQQueue in project activemq-artemis by apache.
the class JMSServerManagerImpl method addQueueToBindingRegistry.
@Override
public boolean addQueueToBindingRegistry(final String queueName, final String registryBinding) throws Exception {
checkInitialised();
checkBindings(registryBinding);
ActiveMQQueue destination = queues.get(queueName);
if (destination == null) {
throw new IllegalArgumentException("Queue does not exist");
}
if (destination.getQueueName() == null) {
throw new IllegalArgumentException(queueName + " is not a queue");
}
boolean added = bindToBindings(registryBinding, destination);
if (added) {
addToBindings(queueBindings, queueName, registryBinding);
storage.addBindings(PersistedType.Queue, queueName, registryBinding);
}
return added;
}
use of org.apache.activemq.artemis.jms.client.ActiveMQQueue in project activemq-artemis by apache.
the class QueueAutoCreationTest method createQueue.
protected Queue createQueue(final String queueName) throws Exception {
SimpleString address = SimpleString.toSimpleString(queueName);
clientSession.createAddress(address, RoutingType.ANYCAST, false);
return new ActiveMQQueue(queueName);
}
use of org.apache.activemq.artemis.jms.client.ActiveMQQueue in project activemq-artemis by apache.
the class StringRefAddrReferenceTest method testActiveMQQueueFromPropertiesJNDI.
@Test(timeout = 10000)
public void testActiveMQQueueFromPropertiesJNDI() throws Exception {
Properties properties = new Properties();
properties.setProperty(TYPE, ActiveMQQueue.class.getName());
properties.setProperty(FACTORY, JNDIReferenceFactory.class.getName());
String address = "foo.bar.queue";
properties.setProperty("address", address);
Reference reference = from(properties);
ActiveMQQueue object = getObject(reference, ActiveMQQueue.class);
assertEquals(address, object.getAddress());
}
use of org.apache.activemq.artemis.jms.client.ActiveMQQueue in project activemq-artemis by apache.
the class LargeMessageQueueAutoCreationTest method createCoreQueue.
protected Queue createCoreQueue(final String queueName) throws Exception {
SimpleString address = SimpleString.toSimpleString(queueName);
clientSession.createAddress(address, RoutingType.ANYCAST, false);
return new ActiveMQQueue(queueName);
}
Aggregations