use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class JMSTest method testJmsProducer.
@Test
public void testJmsProducer() throws Exception {
String queueName = "testQueue";
String prefixedQueueName = ActiveMQDestination.createQueueAddressFromName(queueName).toString();
System.out.println("Queue name: " + prefixedQueueName);
QueueDeployment deployment = new QueueDeployment();
deployment.setDuplicatesAllowed(true);
deployment.setDurableSend(false);
deployment.setName(queueName);
manager.getQueueManager().deploy(deployment);
ClientRequest request = new ClientRequest(generateURL(Util.getUrlPath(queueName)));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, true);
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("consume-next: " + consumeNext);
// test that Accept header is used to set content-type
{
Order order = new Order();
order.setName("1");
order.setAmount("$5.00");
publish(prefixedQueueName, order, null);
ClientResponse<?> res = consumeNext.request().header("Accept-Wait", "2").accept("application/xml").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("application/xml", res.getHeaders().getFirst("Content-Type").toString().toLowerCase());
Order order2 = res.getEntity(Order.class);
res.releaseConnection();
Assert.assertEquals(order, order2);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
Assert.assertNotNull(consumeNext);
}
// test that Accept header is used to set content-type
{
Order order = new Order();
order.setName("1");
order.setAmount("$5.00");
publish(prefixedQueueName, order, null);
ClientResponse<?> res = consumeNext.request().header("Accept-Wait", "2").accept("application/json").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("application/json", res.getHeaders().getFirst("Content-Type").toString().toLowerCase());
Order order2 = res.getEntity(Order.class);
res.releaseConnection();
Assert.assertEquals(order, order2);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
Assert.assertNotNull(consumeNext);
}
// test that message property is used to set content type
{
Order order = new Order();
order.setName("2");
order.setAmount("$15.00");
publish(prefixedQueueName, order, "application/xml");
ClientResponse<?> res = consumeNext.request().header("Accept-Wait", "2").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("application/xml", res.getHeaders().getFirst("Content-Type").toString().toLowerCase());
Order order2 = res.getEntity(Order.class);
res.releaseConnection();
Assert.assertEquals(order, order2);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
Assert.assertNotNull(consumeNext);
}
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class DupQueueTest method testDupWithId.
@Test
public void testDupWithId() throws Exception {
String testName = "testDupWithId";
QueueDeployment deployment = new QueueDeployment();
deployment.setDuplicatesAllowed(false);
deployment.setDurableSend(false);
deployment.setName(testName);
manager.getQueueManager().deploy(deployment);
ClientRequest request = new ClientRequest(generateURL("/queues/" + testName));
ClientResponse<?> response = request.head();
response.releaseConnection();
Assert.assertEquals(200, response.getStatus());
Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create-with-id");
System.out.println("create: " + sender);
Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
System.out.println("pull: " + consumers);
response = Util.setAutoAck(consumers, true);
Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
System.out.println("poller: " + consumeNext);
ClientResponse<?> res = sender.request().pathParameter("id", "1").body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
res = sender.request().body("text/plain", Integer.toString(1)).pathParameter("id", "1").post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "create-next");
res = sender.request().body("text/plain", Integer.toString(2)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
res = consumeNext.request().post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("1", res.getEntity(String.class));
res.releaseConnection();
Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
System.out.println("consumeNext: " + consumeNext);
res = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
Assert.assertEquals(200, res.getStatus());
Assert.assertEquals("2", res.getEntity(String.class));
res.releaseConnection();
session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
System.out.println("session: " + session);
consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
System.out.println("consumeNext: " + consumeNext);
res = consumeNext.request().post(String.class);
res.releaseConnection();
Assert.assertEquals(503, res.getStatus());
res = session.request().delete();
res.releaseConnection();
Assert.assertEquals(204, res.getStatus());
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class ClientAckQueueTest method testPullX2.
@Test
public void testPullX2() throws Exception {
String testName = "testPullX2";
QueueDeployment queueDeployment = new QueueDeployment(testName, true);
manager.getQueueManager().deploy(queueDeployment);
manager.getQueueManager().setLinkStrategy(new LinkHeaderLinkStrategy());
testPull(1, testName);
manager.getQueueManager().setLinkStrategy(new CustomHeaderLinkStrategy());
testPull(4, testName);
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class ClientAckQueueTest method setup.
@BeforeClass
public static void setup() throws Exception {
QueueDeployment deployment1 = new QueueDeployment("testQueue", true);
manager.getQueueManager().deploy(deployment1);
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class ClientAckQueueTest method testAckTimeoutX2.
@Test
public void testAckTimeoutX2() throws Exception {
QueueDeployment deployment = new QueueDeployment();
deployment.setConsumerSessionTimeoutSeconds(1);
deployment.setDuplicatesAllowed(true);
deployment.setDurableSend(false);
deployment.setName("testAck");
manager.getQueueManager().deploy(deployment);
manager.getQueueManager().setLinkStrategy(new LinkHeaderLinkStrategy());
testAckTimeout();
manager.getQueueManager().setLinkStrategy(new CustomHeaderLinkStrategy());
testAckTimeout();
}
Aggregations