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);
}
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());
}
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);
}
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();
}
}
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();
}
}
Aggregations