Java Code Examples for org.jboss.resteasy.client.ClientRequest#head()

The following examples show how to use org.jboss.resteasy.client.ClientRequest#head() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReceiveOrder.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
   // first get the create URL for the shipping queue
   ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
   ClientResponse res = request.head();
   Link pullConsumers = res.getHeaderAsLink("msg-pull-consumers");
   res.releaseConnection();
   res = pullConsumers.request().post();
   Link consumeNext = res.getHeaderAsLink("msg-consume-next");
   res.releaseConnection();
   while (true) {
      System.out.println("Waiting...");
      res = consumeNext.request().header("Accept-Wait", "10").post();
      if (res.getStatus() == 503) {
         System.out.println("Timeout...");
         consumeNext = res.getHeaderAsLink("msg-consume-next");
      } else if (res.getStatus() == 200) {
         Order order = (Order) res.getEntity(Order.class);
         System.out.println(order);
         consumeNext = res.getHeaderAsLink("msg-consume-next");
      } else {
         throw new RuntimeException("Failure! " + res.getStatus());
      }
      res.releaseConnection();
   }
}
 
Example 2
Source File: RestSend.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
   // first get the create URL for the shipping queue
   ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
   ClientResponse res = request.head();
   Link create = res.getHeaderAsLink("msg-create");

   System.out.println("Send order...");
   Order order = new Order();
   order.setName("Bill");
   order.setItem("iPhone4");
   order.setAmount("$199.99");

   res = create.request().body("application/xml", order).post();
   if (res.getStatus() != 201)
      throw new RuntimeException("Failed to post");
}
 
Example 3
Source File: PushReg.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
   // get the push consumers factory resource
   ClientRequest request = new ClientRequest("http://localhost:8080/queues/orders");
   ClientResponse res = request.head();
   Link pushConsumers = res.getHeaderAsLink("msg-push-consumers");

   // next create the XML document that represents the registration
   // Really, just create a link with the shipping URL and the type you want posted
   PushRegistration reg = new PushRegistration();
   XmlLink target = new XmlLink();
   target.setHref("http://localhost:8080/queues/shipping");
   target.setType("application/xml");
   target.setRelationship("destination");
   reg.setTarget(target);

   res = pushConsumers.request().body("application/xml", reg).post();
   System.out.println("Create push registration.  Resource URL: " + res.getLocationLink().getHref());
}
 
Example 4
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testPostOnOldConsumeNext() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, true);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("resource consume-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().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");
   log.debug("session: " + session);
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   Link firstConsumeNext = consumeNext;
   log.debug("session 1st consumeNext: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
   log.debug("session: " + session);
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("session 2nd consumeNext: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(3)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("3", response.getEntity(String.class));
   response.releaseConnection();

   response = firstConsumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(412, response.getStatus());
   log.debug(response.getEntity(String.class));
   response.releaseConnection();

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 5
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testRepostAckAfterUnacknowledge() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, false);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("resource acknowledge-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().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");
   log.debug("session: " + session);
   Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "false").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   response = ack.request().formParameter("acknowledge", "true").post();
   Assert.assertEquals(412, response.getStatus());
   log.debug(response.getEntity(String.class));
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("session 1st acknowledge-next: " + consumeNext);

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 6
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testRestartOnDurableNamedSubscriber() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = consumers.request().formParameter("name", "bill").formParameter("durable", "true").post();
   response.releaseConnection();

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());
   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   manager.getTopicManager().getDestination().findTopic("testTopic").getSubscriptions().stop();

   // recreate subscription a second time as named.  Should pick up old one.

   response = consumers.request().formParameter("name", "bill").formParameter("durable", "true").post();
   response.releaseConnection();
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("resource consume-next: " + consumeNext);
   response = consumeNext.request().header("Accept-Wait", "2").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   response = consumeNext.request().header("Accept-Wait", "2").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", 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());
}
 
Example 7
Source File: PersistentPushTopicConsumerTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testFailure() throws Exception {
   try {
      String testName = "testFailure";
      startup();
      deployTopic(testName);

      ClientRequest request = new ClientRequest(generateURL("/topics/" + testName));

      ClientResponse<?> response = request.head();
      response.releaseConnection();
      Assert.assertEquals(200, response.getStatus());
      Link sender = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
      log.debug("create: " + sender);
      Link pushSubscriptions = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "push-subscriptions");
      log.debug("push subscriptions: " + pushSubscriptions);

      PushTopicRegistration reg = new PushTopicRegistration();
      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();
      PushTopicRegistration reg2 = response.getEntity(PushTopicRegistration.class);
      response.releaseConnection();
      Assert.assertEquals(reg.isDurable(), reg2.isDurable());
      Assert.assertEquals(reg.getTarget().getHref(), reg2.getTarget().getHref());
      Assert.assertFalse(reg2.isEnabled());
      response.releaseConnection();

      String destination = reg2.getDestination();
      ClientSession session = manager.getQueueManager().getSessionFactory().createSession(false, false, false);
      ClientSession.QueueQuery query = session.queueQuery(new SimpleString(destination));
      Assert.assertFalse(query.isExists());

      manager.getQueueManager().getPushStore().removeAll();
   } finally {
      shutdown();
   }
}
 
Example 8
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testPostOnSameConsumeNext() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, true);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("resource consume-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().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");
   log.debug("session: " + session);
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("session 1st consumeNext: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();

   session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
   log.debug("session: " + session);
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("session 2nd consumeNext: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(3)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("3", response.getEntity(String.class));
   response.releaseConnection();

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 9
Source File: AutoAckQueueTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@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");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
   log.debug("pull: " + consumers);
   log.debug("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");
   log.debug("poller: " + consumeNext);

   ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
   res.releaseConnection();
   Assert.assertEquals(201, res.getStatus());
   log.debug("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");
   log.debug("session: " + session);
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
   log.debug("consumeNext: " + consumeNext);

   log.debug(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");
   log.debug("session: " + session);
   getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consume-next");
   log.debug("consumeNext: " + consumeNext);

   res = session.request().delete();
   res.releaseConnection();
   Assert.assertEquals(204, res.getStatus());
}
 
Example 10
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testReconnectOnNamedSubscriber() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = consumers.request().formParameter("name", "bill").post();
   response.releaseConnection();

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());
   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   // recreate subscription a second time as named.  Should pick up old one.

   response = consumers.request().formParameter("name", "bill").post();
   response.releaseConnection();
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("resource consume-next: " + consumeNext);
   response = consumeNext.request().post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   response = consumeNext.request().header("Accept-Wait", "2").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", 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());
}
 
Example 11
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testPostOnOldAcknowledgeNextAndAck() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, false);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("resource acknowledge-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "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");
   log.debug("session: " + session);
   Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   Link oldAck = ack;
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("session 1st acknowledge-next: " + consumeNext);
   Link firstConsumeNext = consumeNext;

   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);

   response = oldAck.request().formParameter("acknowledge", "true").post();
   Assert.assertEquals(412, response.getStatus());
   log.debug(response.getEntity(String.class));
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");

   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");

   response = consumeNext.request().post(String.class);
   response.releaseConnection();
   Assert.assertEquals(503, response.getStatus());

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 12
Source File: AutoAckTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testNewSubNotBlockedByTimeoutTask() throws Exception {
   // Default config is 1s interval, 300s timeout.

   // Create a topic
   String testName = "AutoAckTopicTest.testNewSubNotBlockedByTimeoutTask";
   TopicDeployment deployment = new TopicDeployment();
   deployment.setDuplicatesAllowed(true);
   deployment.setDurableSend(false);
   deployment.setName(testName);
   manager.getTopicManager().deploy(deployment);

   // Create a consumer
   ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/topics/" + testName));
   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create");
   Link subscriptions = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "pull-subscriptions");

   // Create the pull-subscription itself.
   ClientResponse<?> res = subscriptions.request().post();
   res.releaseConnection();
   Assert.assertEquals(201, res.getStatus());
   Link sub1 = res.getLocationLink();
   Assert.assertNotNull(sub1);
   Link consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
   Assert.assertNotNull(consumeNext1);

   // Pull on the topic for 8s (long enoguh to guarantee the rest of the test
   // will pass/fail due to the timeouttask + test operations)
   AcceptWaitListener awlistener = new AcceptWaitListener(consumeNext1.getHref());
   Thread t = new Thread(awlistener);
   t.start();
   // Wait 2 seconds to ensure a new TimeoutTask is running concurrently.
   Thread.sleep(2000);
   // Attempt to create a new pull-subscription. Validate that it takes no longer than 2 seconds
   // (it should take like 20ms, but give it a relatively huge amount of leeway)
   NewPullSubscriber nps = new NewPullSubscriber(subscriptions.getHref());
   Thread npsThread = new Thread(nps);
   npsThread.start();
   Thread.sleep(2000);
   Assert.assertTrue("NewPullSubscriber did not finish in 2 seconds!", nps.isFinished());
   Assert.assertFalse("AcceptWaitListener failed to open connection!", awlistener.isFailed());
   Assert.assertFalse("NewPullSubscriber failed to open new subscription!", nps.isFailed());
   npsThread.interrupt();
   t.interrupt();
}
 
Example 13
Source File: SessionTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testTopicRestartFromAutoAckSession() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, true);
   Link session = response.getLocationLink();
   response = session.request().head();
   response.releaseConnection();
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("consume-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = session.request().get();
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");

   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = session.request().head();
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");

   response = sender.request().body("text/plain", Integer.toString(3)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("3", response.getEntity(String.class));
   response.releaseConnection();

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 14
Source File: SessionTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testRestartFromAutoAckSession() throws Exception {
   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");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, true);
   Link session = response.getLocationLink();
   response = session.request().head();
   response.releaseConnection();
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("consume-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = session.request().get();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");

   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = session.request().head();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");

   response = sender.request().body("text/plain", Integer.toString(3)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("3", response.getEntity(String.class));
   response.releaseConnection();

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 15
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testRepostAckAfterUnacknowledge() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, false);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("resource acknowledge-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().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");
   log.debug("session: " + session);
   Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "false").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   response = ack.request().formParameter("acknowledge", "true").post();
   Assert.assertEquals(412, response.getStatus());
   log.debug(response.getEntity(String.class));
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("session 1st acknowledge-next: " + consumeNext);

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 16
Source File: CreateDestinationTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreateTopic() throws Exception {
   String queueConfig = "<topic name=\"testTopic\"></topic>";
   ClientRequest create = new ClientRequest(TestPortProvider.generateURL("/topics"));
   ClientResponse cRes = create.body("application/activemq.jms.topic+xml", queueConfig).post();
   cRes.releaseConnection();
   Assert.assertEquals(201, cRes.getStatus());

   ClientRequest request = cRes.getLocationLink().request();

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create");
   Link subscriptions = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "pull-subscriptions");

   ClientResponse<?> res = subscriptions.request().post();
   res.releaseConnection();
   Assert.assertEquals(201, res.getStatus());
   Link sub1 = res.getLocationLink();
   Assert.assertNotNull(sub1);
   Link consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
   Assert.assertNotNull(consumeNext1);
   log.debug("consumeNext1: " + consumeNext1);

   res = subscriptions.request().post();
   res.releaseConnection();
   Assert.assertEquals(201, res.getStatus());
   Link sub2 = res.getLocationLink();
   Assert.assertNotNull(sub2);
   Link consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
   Assert.assertNotNull(consumeNext1);

   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(2)).post();
   res.releaseConnection();
   Assert.assertEquals(201, res.getStatus());

   res = consumeNext1.request().post(String.class);
   Assert.assertEquals(200, res.getStatus());
   Assert.assertEquals("1", res.getEntity(String.class));
   res.releaseConnection();
   consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");

   res = consumeNext1.request().post(String.class);
   Assert.assertEquals(200, res.getStatus());
   Assert.assertEquals("2", res.getEntity(String.class));
   res.releaseConnection();
   consumeNext1 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");

   res = consumeNext2.request().post(String.class);
   Assert.assertEquals(200, res.getStatus());
   Assert.assertEquals("1", res.getEntity(String.class));
   res.releaseConnection();
   consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");

   res = consumeNext2.request().post(String.class);
   Assert.assertEquals(200, res.getStatus());
   Assert.assertEquals("2", res.getEntity(String.class));
   res.releaseConnection();
   consumeNext2 = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), res, "consume-next");
   res = sub1.request().delete();
   res.releaseConnection();
   Assert.assertEquals(204, res.getStatus());
   res = sub2.request().delete();
   res.releaseConnection();
   Assert.assertEquals(204, res.getStatus());
}
 
Example 17
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testPostOnSameConsumeNextWithTimeout() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, true);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("resource consume-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().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");
   log.debug("session: " + session);
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("session 1st consumeNext: " + consumeNext);

   // test timeout here
   response = consumeNext.request().post(String.class);
   response.releaseConnection();
   Assert.assertEquals(503, response.getStatus());
   session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
   log.debug("session: " + session);
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
   log.debug("session 2nd consumeNext: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(3)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("3", response.getEntity(String.class));
   response.releaseConnection();

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 18
Source File: RepostingQueueTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testRepostAckAfterUnacknowledge() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/queues/testQueue"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, false);
   Link consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("resource acknowledge-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "1").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   Link session = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consumer");
   log.debug("session: " + session);
   Link ack = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "false").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   response = ack.request().formParameter("acknowledge", "true").post();
   Assert.assertEquals(412, response.getStatus());
   log.debug(response.getEntity(String.class));
   response.releaseConnection();
   consumeNext = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("session 1st acknowledge-next: " + consumeNext);

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("1", response.getEntity(String.class));
   response.releaseConnection();
   ack = MessageTestBase.getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 19
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testPostOnOldAcknowledgeNextAndAck() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, false);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("resource acknowledge-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "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");
   log.debug("session: " + session);
   Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   Link oldAck = ack;
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("session 1st acknowledge-next: " + consumeNext);
   Link firstConsumeNext = consumeNext;

   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);

   response = oldAck.request().formParameter("acknowledge", "true").post();
   Assert.assertEquals(412, response.getStatus());
   log.debug(response.getEntity(String.class));
   response.releaseConnection();
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");

   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");

   response = consumeNext.request().post(String.class);
   response.releaseConnection();
   Assert.assertEquals(503, response.getStatus());

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}
 
Example 20
Source File: RepostingTopicTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testPostOnSameAcknowledgeNextAndAck() throws Exception {
   ClientRequest request = new ClientRequest(generateURL("/topics/testTopic"));

   ClientResponse<?> response = request.head();
   response.releaseConnection();
   Assert.assertEquals(200, response.getStatus());
   Link sender = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "create");
   log.debug("create: " + sender);
   Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-subscriptions");
   log.debug("pull: " + consumers);
   response = Util.setAutoAck(consumers, false);
   Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("resource acknowledge-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(1)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().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");
   log.debug("session: " + session);
   Link ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
   consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledge-next");
   log.debug("session 1st acknowledge-next: " + consumeNext);

   response = sender.request().body("text/plain", Integer.toString(2)).post();
   response.releaseConnection();
   Assert.assertEquals(201, response.getStatus());

   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   response = consumeNext.request().header(Constants.WAIT_HEADER, "10").post(String.class);
   Assert.assertEquals(200, response.getStatus());
   Assert.assertEquals("2", response.getEntity(String.class));
   response.releaseConnection();
   ack = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "acknowledgement");
   log.debug("ack: " + ack);
   response = ack.request().formParameter("acknowledge", "true").post();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());

   response = session.request().delete();
   response.releaseConnection();
   Assert.assertEquals(204, response.getStatus());
}