Search in sources :

Example 1 with QueueDeployment

use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.

the class PushTopicConsumerTest method testTemplate.

@Test
public void testTemplate() throws Exception {
    TopicDeployment deployment = new TopicDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName("testTemplate");
    manager.getTopicManager().deploy(deployment);
    QueueDeployment deployment2 = new QueueDeployment();
    deployment2.setDuplicatesAllowed(true);
    deployment2.setDurableSend(false);
    deployment2.setName("testTemplateForwardQueue");
    manager.getQueueManager().deploy(deployment2);
    ClientRequest request = new ClientRequest(generateURL("/topics/testTemplate"));
    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 pushSubscriptions = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "push-subscriptions");
    System.out.println("push subscriptions: " + pushSubscriptions);
    request = new ClientRequest(generateURL("/queues/testTemplateForwardQueue"));
    response = request.head();
    response.releaseConnection();
    Assert.assertEquals(200, response.getStatus());
    Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
    Link createWithId = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create-with-id");
    response = Util.setAutoAck(consumers, true);
    Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
    PushTopicRegistration reg = new PushTopicRegistration();
    reg.setDurable(false);
    XmlLink target = new XmlLink();
    target.setRelationship("template");
    target.setHref(createWithId.getHref());
    reg.setTarget(target);
    response = pushSubscriptions.request().body("application/xml", reg).post();
    Assert.assertEquals(201, response.getStatus());
    Link pushSubscription = response.getLocationLink();
    response.releaseConnection();
    response = sender.request().body("text/plain", Integer.toString(1)).post();
    response.releaseConnection();
    Assert.assertEquals(201, response.getStatus());
    response = consumeNext.request().header("Accept-Wait", "1").post(String.class);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("1", response.getEntity(String.class));
    response.releaseConnection();
    Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
    response = session.request().delete();
    response.releaseConnection();
    Assert.assertEquals(204, response.getStatus());
    response = pushSubscription.request().delete();
    response.releaseConnection();
    Assert.assertEquals(204, response.getStatus());
}
Also used : PushTopicRegistration(org.apache.activemq.artemis.rest.topic.PushTopicRegistration) TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment) XmlLink(org.apache.activemq.artemis.rest.queue.push.xml.XmlLink) ClientRequest(org.jboss.resteasy.client.ClientRequest) XmlLink(org.apache.activemq.artemis.rest.queue.push.xml.XmlLink) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 2 with QueueDeployment

use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.

the class PushTopicConsumerTest method testClass.

@Test
public void testClass() throws Exception {
    TopicDeployment deployment = new TopicDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName("testClass");
    manager.getTopicManager().deploy(deployment);
    QueueDeployment deployment2 = new QueueDeployment();
    deployment2.setDuplicatesAllowed(true);
    deployment2.setDurableSend(false);
    deployment2.setName("testClassForwardQueue");
    manager.getQueueManager().deploy(deployment2);
    ClientRequest request = new ClientRequest(generateURL("/topics/testClass"));
    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 pushSubscriptions = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "push-subscriptions");
    System.out.println("push subscriptions: " + pushSubscriptions);
    request = new ClientRequest(generateURL("/queues/testClassForwardQueue"));
    response = request.head();
    response.releaseConnection();
    Assert.assertEquals(200, response.getStatus());
    Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
    response = Util.setAutoAck(consumers, true);
    Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
    PushTopicRegistration reg = new PushTopicRegistration();
    reg.setDurable(false);
    XmlLink target = new XmlLink();
    target.setHref(generateURL("/queues/testClassForwardQueue"));
    target.setClassName(ActiveMQPushStrategy.class.getName());
    reg.setTarget(target);
    response = pushSubscriptions.request().body("application/xml", reg).post();
    Assert.assertEquals(201, response.getStatus());
    Link pushSubscription = response.getLocationLink();
    response.releaseConnection();
    response = sender.request().body("text/plain", Integer.toString(1)).post();
    response.releaseConnection();
    Assert.assertEquals(201, response.getStatus());
    response = consumeNext.request().header("Accept-Wait", "1").post(String.class);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("1", response.getEntity(String.class));
    response.releaseConnection();
    Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
    response = session.request().delete();
    response.releaseConnection();
    Assert.assertEquals(204, response.getStatus());
    response = pushSubscription.request().delete();
    response.releaseConnection();
    Assert.assertEquals(204, response.getStatus());
}
Also used : PushTopicRegistration(org.apache.activemq.artemis.rest.topic.PushTopicRegistration) ActiveMQPushStrategy(org.apache.activemq.artemis.rest.queue.push.ActiveMQPushStrategy) TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment) XmlLink(org.apache.activemq.artemis.rest.queue.push.xml.XmlLink) ClientRequest(org.jboss.resteasy.client.ClientRequest) XmlLink(org.apache.activemq.artemis.rest.queue.push.xml.XmlLink) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 3 with QueueDeployment

use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.

the class SessionTest method setup.

@BeforeClass
public static void setup() throws Exception {
    QueueDeployment deployment1 = new QueueDeployment("testQueue", true);
    manager.getQueueManager().deploy(deployment1);
    TopicDeployment deployment = new TopicDeployment();
    deployment.setConsumerSessionTimeoutSeconds(1);
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName("testTopic");
    manager.getTopicManager().deploy(deployment);
}
Also used : TopicDeployment(org.apache.activemq.artemis.rest.topic.TopicDeployment) QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment) BeforeClass(org.junit.BeforeClass)

Example 4 with QueueDeployment

use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.

the class AutoAckQueueTest method testSuccessFirst.

@Test
public void testSuccessFirst() throws Exception {
    String testName = "testSuccessFirst";
    QueueDeployment deployment = new QueueDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName(testName);
    manager.getQueueManager().deploy(deployment);
    ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/queues/" + testName));
    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);
    System.out.println("create-with-id: " + getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create-with-id"));
    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();
    res.releaseConnection();
    Assert.assertEquals(201, res.getStatus());
    System.out.println("create-next: " + 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);
    System.out.println(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);
    getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
    System.out.println("consumeNext: " + consumeNext);
    res = session.request().delete();
    res.releaseConnection();
    Assert.assertEquals(204, res.getStatus());
}
Also used : QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment) ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) Test(org.junit.Test)

Example 5 with QueueDeployment

use of org.apache.activemq.artemis.rest.queue.QueueDeployment in project activemq-artemis by apache.

the class ClientAckQueueTest method testSuccessFirstX2.

@Test
public void testSuccessFirstX2() throws Exception {
    String testName = "testSuccessFirstX2";
    QueueDeployment queueDeployment = new QueueDeployment(testName, true);
    manager.getQueueManager().deploy(queueDeployment);
    manager.getQueueManager().setLinkStrategy(new LinkHeaderLinkStrategy());
    testSuccessFirst(1, testName);
    manager.getQueueManager().setLinkStrategy(new CustomHeaderLinkStrategy());
    testSuccessFirst(3, testName);
}
Also used : CustomHeaderLinkStrategy(org.apache.activemq.artemis.rest.util.CustomHeaderLinkStrategy) QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment) LinkHeaderLinkStrategy(org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy) Test(org.junit.Test)

Aggregations

QueueDeployment (org.apache.activemq.artemis.rest.queue.QueueDeployment)21 Test (org.junit.Test)15 ClientRequest (org.jboss.resteasy.client.ClientRequest)11 Link (org.jboss.resteasy.spi.Link)11 XmlLink (org.apache.activemq.artemis.rest.queue.push.xml.XmlLink)4 TopicDeployment (org.apache.activemq.artemis.rest.topic.TopicDeployment)4 CustomHeaderLinkStrategy (org.apache.activemq.artemis.rest.util.CustomHeaderLinkStrategy)4 LinkHeaderLinkStrategy (org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy)4 BeforeClass (org.junit.BeforeClass)4 PushTopicRegistration (org.apache.activemq.artemis.rest.topic.PushTopicRegistration)3 Connection (javax.jms.Connection)1 Destination (javax.jms.Destination)1 MessageConsumer (javax.jms.MessageConsumer)1 MessageListener (javax.jms.MessageListener)1 Session (javax.jms.Session)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1 ActiveMQDestination (org.apache.activemq.artemis.jms.client.ActiveMQDestination)1 ActiveMQPushStrategy (org.apache.activemq.artemis.rest.queue.push.ActiveMQPushStrategy)1 PushRegistration (org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration)1 ClientResponse (org.jboss.resteasy.client.ClientResponse)1