Search in sources :

Example 16 with QueueDeployment

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

the class PushQueueConsumerTest method deployQueue.

private void deployQueue(String queueName) throws Exception {
    QueueDeployment deployment = new QueueDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName(queueName);
    manager.getQueueManager().deploy(deployment);
}
Also used : QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment)

Example 17 with QueueDeployment

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

the class PushTopicConsumerTest method testBridge.

@Test
public void testBridge() throws Exception {
    TopicDeployment deployment = new TopicDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName("testBridge");
    manager.getTopicManager().deploy(deployment);
    QueueDeployment deployment2 = new QueueDeployment();
    deployment2.setDuplicatesAllowed(true);
    deployment2.setDurableSend(false);
    deployment2.setName("testBridgeForwardQueue");
    manager.getQueueManager().deploy(deployment2);
    ClientRequest request = new ClientRequest(generateURL("/topics/testBridge"));
    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/testBridgeForwardQueue"));
    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/testBridgeForwardQueue"));
    target.setRelationship("destination");
    reg.setTarget(target);
    response = pushSubscriptions.request().body("application/xml", reg).post();
    response.releaseConnection();
    Assert.assertEquals(201, response.getStatus());
    Link pushSubscription = response.getLocationLink();
    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 18 with QueueDeployment

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

the class RepostingQueueTest method setup.

@BeforeClass
public static void setup() throws Exception {
    QueueDeployment deployment1 = new QueueDeployment("testQueue", true);
    manager.getQueueManager().deploy(deployment1);
}
Also used : QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment) BeforeClass(org.junit.BeforeClass)

Example 19 with QueueDeployment

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

the class RoundtripTimeTest method testSuccessFirst.

@Test
public void testSuccessFirst() throws Exception {
    QueueDeployment deployment = new QueueDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    deployment.setName("testQueue");
    manager.getQueueManager().deploy(deployment);
    ClientRequest request = new ClientRequest(generateURL("/queues/testQueue"));
    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);
    long start = System.currentTimeMillis();
    int num = 100;
    for (int i = 0; i < num; i++) {
        response = sender.request().body("text/plain", Integer.toString(i + 1)).post();
        response.releaseConnection();
    }
    long end = System.currentTimeMillis() - start;
    System.out.println(num + " iterations took " + end + "ms");
    for (int i = 0; i < num; i++) {
        response = consumeNext.request().post(String.class);
        consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals(Integer.toString(i + 1), response.getEntity(String.class));
        response.releaseConnection();
    }
}
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 20 with QueueDeployment

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

the class TransformTest method testJmsConsumer.

@Test
public void testJmsConsumer() throws Exception {
    QueueDeployment deployment = new QueueDeployment();
    deployment.setDuplicatesAllowed(true);
    deployment.setDurableSend(false);
    final String queueName = "testJmsConsumer";
    deployment.setName(queueName);
    manager.getQueueManager().deploy(deployment);
    ClientSession session = manager.getQueueManager().getSessionFactory().createSession();
    try {
        session.createConsumer(queueName).setMessageHandler(new Listener());
        session.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 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");
            response = sender.request().body("application/xml", order).post();
            response.releaseConnection();
            Assert.assertEquals(201, response.getStatus());
            Listener.latch.await(2, TimeUnit.SECONDS);
            Assert.assertNotNull(Listener.order);
            Assert.assertEquals(order, Listener.order);
        }
    } finally {
        session.close();
    }
}
Also used : QueueDeployment(org.apache.activemq.artemis.rest.queue.QueueDeployment) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) 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