org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration

Here are the examples of the java api class org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration taken from open source projects.

1. PushReg#main()

Project: activemq-artemis
Source File: PushReg.java
View license
public static void main(String[] args) throws Exception {
    // get the push consumers factory resource
    ClientRequest request = new ClientRequest("http://localhost:9095/queues/jms.queue.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();
    BasicAuth authType = new BasicAuth();
    authType.setUsername("guest");
    authType.setPassword("guest");
    Authentication auth = new Authentication();
    auth.setType(authType);
    reg.setAuthenticationMechanism(auth);
    XmlLink target = new XmlLink();
    target.setHref("http://localhost:9095/queues/jms.queue.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());
}

2. XmlTest#testPush()

Project: activemq-artemis
Source File: XmlTest.java
View license
@Test
public void testPush() throws Exception {
    String xml = "<push-registration id=\"111\">\n" + "   <destination>jms.queue.bar</destination>\n" + "   <durable>true</durable>\n" + "   <session-count>10</session-count>\n" + "   <link rel=\"template\" href=\"http://somewhere.com/resources/{id}/messages\" method=\"PUT\"/>\n" + "   <authentication>\n" + "      <basic-auth><username>guest</username><password>geheim</password></basic-auth>" + "   </authentication>\n" + "   <header name=\"foo\">bar</header>" + "</push-registration>";
    JAXBContext ctx = JAXBContext.newInstance(PushRegistration.class);
    PushRegistration reg = (PushRegistration) ctx.createUnmarshaller().unmarshal(new StringReader(xml));
    System.out.println(reg);
}

3. PushQueueConsumerTest#createPushRegistration()

View license
private Link createPushRegistration(String queueToPushTo, Link pushSubscriptions, PushRegistrationType pushRegistrationType, int sessionCount) throws Exception {
    PushRegistration reg = new PushRegistration();
    reg.setDurable(false);
    XmlLink target = new XmlLink();
    if (pushRegistrationType == PushRegistrationType.CLASS) {
        target.setHref(generateURL(Util.getUrlPath(queueToPushTo)));
        target.setClassName(ActiveMQPushStrategy.class.getName());
    } else if (pushRegistrationType == PushRegistrationType.BRIDGE) {
        target.setHref(generateURL(Util.getUrlPath(queueToPushTo)));
        target.setRelationship("destination");
    } else if (pushRegistrationType == PushRegistrationType.TEMPLATE) {
        target.setHref(queueToPushTo);
        target.setRelationship("template");
    } else if (pushRegistrationType == PushRegistrationType.URI) {
        target.setMethod("put");
        target.setHref(queueToPushTo);
    }
    reg.setTarget(target);
    reg.setSessionCount(sessionCount);
    ClientResponse pushRegistrationResponse = pushSubscriptions.request().body("application/xml", reg).post();
    pushRegistrationResponse.releaseConnection();
    Assert.assertEquals(201, pushRegistrationResponse.getStatus());
    Link pushSubscription = pushRegistrationResponse.getLocationLink();
    return pushSubscription;
}

4. FilePushStore#getByDestination()

Project: activemq-artemis
Source File: FilePushStore.java
View license
@Override
public synchronized List<PushRegistration> getByDestination(String destination) {
    List<PushRegistration> list = new ArrayList<>();
    for (PushRegistration reg : map.values()) {
        if (reg.getDestination().equals(destination)) {
            list.add(reg);
        }
    }
    return list;
}

5. FilePushStore#removeAll()

Project: activemq-artemis
Source File: FilePushStore.java
View license
@Override
public synchronized void removeAll() throws Exception {
    ArrayList<PushRegistration> copy = new ArrayList<>(map.values());
    for (PushRegistration reg : copy) remove(reg);
    this.dir.delete();
}

6. FileTopicPushStore#getByTopic()

View license
@Override
public synchronized List<PushTopicRegistration> getByTopic(String topic) {
    List<PushTopicRegistration> list = new ArrayList<>();
    for (PushRegistration reg : map.values()) {
        PushTopicRegistration topicReg = (PushTopicRegistration) reg;
        if (topicReg.getTopic().equals(topic)) {
            list.add(topicReg);
        }
    }
    return list;
}