use of org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration in project activemq-artemis by apache.
the class PushReg method main.
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());
}
use of org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration 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();
}
}
Aggregations