use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class ClientAckQueueTest method testReconnectX2.
@Test
public void testReconnectX2() throws Exception {
String testName = "testReconnectX2";
QueueDeployment queueDeployment = new QueueDeployment(testName, true);
manager.getQueueManager().deploy(queueDeployment);
manager.getQueueManager().setLinkStrategy(new LinkHeaderLinkStrategy());
testReconnect(testName);
manager.getQueueManager().setLinkStrategy(new CustomHeaderLinkStrategy());
testReconnect(testName);
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class JMSTest method testJmsConsumer.
@Test
public void testJmsConsumer() throws Exception {
String queueName = "testQueue2";
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);
Connection conn = connectionFactory.createConnection();
try {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = createDestination(prefixedQueueName);
MessageConsumer consumer = session.createConsumer(destination);
consumer.setMessageListener(new Listener());
conn.start();
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 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");
response = sender.request().body("application/xml", order).post();
response.releaseConnection();
Assert.assertEquals(201, response.getStatus());
Listener.latch.await(1, TimeUnit.SECONDS);
Assert.assertNotNull(Listener.order);
Assert.assertEquals(order, Listener.order);
Assert.assertNotNull(Listener.messageID);
}
} finally {
conn.close();
}
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class PersistentPushQueueConsumerTest method testFailure.
@Test
public void testFailure() throws Exception {
try {
startup();
String testName = "testFailure";
QueueDeployment deployment = new QueueDeployment();
deployment.setDuplicatesAllowed(true);
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 = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
System.out.println("create: " + sender);
Link pushSubscriptions = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "push-consumers");
System.out.println("push subscriptions: " + pushSubscriptions);
PushRegistration reg = new PushRegistration();
reg.setDurable(true);
XmlLink target = new XmlLink();
target.setHref("http://localhost:3333/error");
target.setRelationship("uri");
reg.setTarget(target);
reg.setDisableOnFailure(true);
reg.setMaxRetries(3);
reg.setRetryWaitMillis(10);
response = pushSubscriptions.request().body("application/xml", reg).post();
Assert.assertEquals(201, response.getStatus());
Link pushSubscription = response.getLocationLink();
response.releaseConnection();
ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
Thread.sleep(5000);
response = pushSubscription.request().get();
PushRegistration reg2 = response.getEntity(PushRegistration.class);
Assert.assertEquals(reg.isDurable(), reg2.isDurable());
Assert.assertEquals(reg.getTarget().getHref(), reg2.getTarget().getHref());
// make sure the failure disables the PushRegistration
Assert.assertFalse(reg2.isEnabled());
response.releaseConnection();
manager.getQueueManager().getPushStore().removeAll();
} finally {
shutdown();
}
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class PersistentPushQueueConsumerTest method deployBridgeQueues.
private void deployBridgeQueues(String testName) throws Exception {
QueueDeployment deployment = new QueueDeployment();
deployment.setDuplicatesAllowed(true);
deployment.setDurableSend(false);
deployment.setName(testName);
manager.getQueueManager().deploy(deployment);
QueueDeployment deployment2 = new QueueDeployment();
deployment2.setDuplicatesAllowed(true);
deployment2.setDurableSend(false);
deployment2.setName(testName + "forwardQueue");
manager.getQueueManager().deploy(deployment2);
}
use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.
the class DupQueueTest method testDup.
@Test
public void testDup() throws Exception {
String testName = "testDup";
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();
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("poller: " + consumeNext);
ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
Assert.assertEquals(307, res.getStatus());
sender = res.getLocationLink();
res.releaseConnection();
System.out.println("create-next: " + sender);
Assert.assertNotNull(sender);
res = sender.request().body("text/plain", Integer.toString(1)).post();
res.releaseConnection();
Assert.assertEquals(201, res.getStatus());
res = sender.request().body("text/plain", Integer.toString(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());
}
Aggregations