Examples of WseMsgBrokerClient


Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

        subscription = LeadNotificationManager.createSubscription(BROKER_URL, "topic", c1, consumerPort);
        Thread.sleep(100);
        Subscription subscription2 = LeadNotificationManager.createSubscription(BROKER_URL, "topic", c2,
                consumerPort + 1);

        WseMsgBrokerClient client = new WseMsgBrokerClient();
        client.init(BROKER_URL);
        client.setTimeoutInMilliSeconds(20000L);

        OMElement msg = WorkFlowUtils.reader2OMElement(new StringReader(CommonUtils.WORKFLOW_INITIALIZED_NOTIFICATION));

        for (int i = 0; i < repetition; i++) {
            client.publish("topic", msg);
            Thread.sleep(100);
        }

        Boolean b1 = c1.getQueue().take();
        Boolean b2 = c2.getQueue().take();
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

        subscription = LeadNotificationManager.createSubscription(BROKER_URL, "topic10", c1, consumerPort);
        Subscription subscription2 = LeadNotificationManager.createSubscription(BROKER_URL, "topic20", c2,
                consumerPort + 1);

        WseMsgBrokerClient client = new WseMsgBrokerClient();
        client.init(BROKER_URL);

        OMElement msg = WorkFlowUtils.reader2OMElement(new StringReader(CommonUtils.WORKFLOW_INITIALIZED_NOTIFICATION));

        for (int i = 0; i < repetition; i++) {
            client.publish("topic10", msg);
            Thread.sleep(100);
        }

        for (int i = 0; i < repetition; i++) {
            client.publish("topic20", msg);
            Thread.sleep(100);
        }

        Boolean b1 = c1.getQueue().take();
        Boolean b2 = c2.getQueue().take();
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

                    e.printStackTrace();
                }
            }
        };

        WseMsgBrokerClient api = new WseMsgBrokerClient();
        api.init(BROKER_URL);
        int consumerPort = 5555;

        String[] consumerServiceEprs = api.startConsumerService(consumerPort, handler);

        api.subscribe(consumerServiceEprs[0], ">", null);

        String topic = "Foo";
        // if remote broker location specified, use WSMessaging publisher;
        ConstructorProps props = ConstructorProps
                .newProps(ConstructorConsts.ENABLE_ASYNC_PUBLISH, "false")
                .set(ConstructorConsts.ENABLE_BATCH_PROVENANCE, "true")
                .set(ConstructorConsts.ANNOTATIONS,
                        AnnotationProps.newProps(AnnotationConsts.ExperimentID,
                                "experiment-id-" + System.currentTimeMillis()).set(AnnotationConsts.UserDN,
                                "/O=IU/OU=Extreme Lab/CN=drlead"));
        if (BROKER_URL != null) {
            EndpointReference brokerEpr = api.createEndpointReference(BROKER_URL, topic);

            props.set(ConstructorConsts.BROKER_EPR, brokerEpr.getAddress());
        } else {
            props.set(ConstructorConsts.PUBLISHER_IMPL_CLASS,
                    "org.apache.airavata.workflow.tracking.impl.publish.LoopbackPublisher");
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

        .getProperty(ConfigKeys.TOPIC_SIMPLE);

    int timeInterval = Integer.parseInt(configurations
        .getProperty(ConfigKeys.PUBLISH_TIME_INTERVAL));

    WseMsgBrokerClient client = new WseMsgBrokerClient();
    client.init(brokerLocation);

    OMElement omMsg = OMAbstractFactory.getOMFactory().createOMElement(
        "msg", null);
    int sequence = 1;

    try {

      while (true) {

        omMsg.setText("" + (sequence++));

        System.out.println(String.format(
            "producer [%s] sending msg: %s", getName(), omMsg
                .toString()));
        client.publish(topicExpression, omMsg);
        TimeUnit.SECONDS.sleep(timeInterval);
      }

    } catch (InterruptedException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

        thread.stop();

        Thread.sleep(5000);

        System.out.println("bringing down the Puller\n Publishing Messages");
        WseMsgBrokerClient client = new WseMsgBrokerClient();
        client.init(BROKER_URL);

        OMElement msg = WorkFlowUtils.reader2OMElement(new StringReader(CommonUtils.WORKFLOW_INITIALIZED_NOTIFICATION));

        client.publish(TOPIC, msg);

        System.out.println("Messages published");
        System.out.println("Creating another puller");
        EndpointReference epr = thread.getWsaEndpointReference();
        String subscriptionID = thread.getSubscriptionID();
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

    String brokerLocation = configurations
        .getProperty(ConfigKeys.BROKER_EVENTING_SERVICE_EPR);
    String topicExpression = configurations
        .getProperty(ConfigKeys.TOPIC_SIMPLE);

    WseMsgBrokerClient client = new WseMsgBrokerClient();
    client.init(brokerLocation);

    System.out.println("subscribing with topic expression: "
        + topicExpression);

    NotificationMsgReciever msgReciever = new NotificationMsgReciever();

    String[] consumerEprs = null;

    String subscriptionId = null;

    try {
      consumerEprs = client.startConsumerService(consumerPort,
          msgReciever);

    } catch (MsgBrokerClientException e) {

      e.printStackTrace();

      System.out.println("unable to start consumer service, exiting");
      return;
    }

    try {

      subscriptionId = client.subscribe(consumerEprs[0], topicExpression,
          null);
    } catch (MsgBrokerClientException e) {

      e.printStackTrace();

      System.out
          .println("unable to subscribe for the topic consumer exiting");
      return;
    }

    try {

      do {

        SOAPEnvelope env = msgReciever.getQueue().take();

        String msg;
        try {
          msg = env.getBody().getFirstElement().toStringWithConsume();
          System.out.println(String.format(
              "consumer [%s] recieved: %s", getName(), msg));

        } catch (Exception e) {
          System.err.print("invalid msg recieved");
        }

      } while (true);

    } catch (InterruptedException ie) {

      try {
        // unsubscribe from the topic.
        client.unSubscribe(subscriptionId);
      } catch (MsgBrokerClientException e) {

        e.printStackTrace();
        System.out.println("unable to unsubscribe, ignoring");
      }

      // shutdown the consumer service.
      client.shutdownConsumerService();

      System.out.println("interrupted");

    }
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

        .getProperty(ConfigKeys.TOPIC_SIMPLE);

    int timeInterval = Integer.parseInt(configurations
        .getProperty(ConfigKeys.PUBLISH_TIME_INTERVAL));

    WseMsgBrokerClient client = new WseMsgBrokerClient();
    client.init(brokerLocation);

    String msgFormat = "<msg><seq>%d</seq><src>%s</src><uuid>%s</uuid></msg>";

    try {

      int count = 0;
      while (true) {
        UUID uuid = UUID.randomUUID();
        count++;
        String msg = String.format(msgFormat, count, getName(), uuid
            .toString());
        System.out.println(String.format(
            "producer [%s] sending msg: %s", getName(), msg));
        client.publish(topicExpression, buildMsg(msg));
        TimeUnit.SECONDS.sleep(timeInterval);
      }

    } catch (InterruptedException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

    String brokerLocation = configurations
        .getProperty(ConfigKeys.BROKER_EVENTING_SERVICE_EPR);
    String xpathExpression = configurations
        .getProperty(ConfigKeys.TOPIC_XPATH);

    WseMsgBrokerClient client = new WseMsgBrokerClient();
    client.init(brokerLocation);

    System.out.println("subscribing with xpath expression: "
        + xpathExpression);

    NotificationMsgReciever msgReciever = new NotificationMsgReciever();

    String[] consumerEprs = null;

    String subscriptionId = null;

    try {
      consumerEprs = client.startConsumerService(consumerPort,
          msgReciever);

    } catch (MsgBrokerClientException e) {

      e.printStackTrace();

      System.out.println("unable to start consumer service, exiting");
      return;
    }

    try {

      subscriptionId = client.subscribe(consumerEprs[0], null,
          xpathExpression);
      System.out.println(getName() + "got the subscription id :"
          + subscriptionId);

    } catch (MsgBrokerClientException e) {

      e.printStackTrace();

      System.out
          .println("unable to subscribe for the xpath consumer exiting");
      return;
    }

    try {

      do {

        SOAPEnvelope env = msgReciever.getQueue().take();

        String msg;
        try {
          msg = env.getBody().getFirstElement().toStringWithConsume();
          System.out.println(String.format(
              "consumer [%s] recieved: %s", getName(), msg));

        } catch (Exception e) {
          System.err.print("invalid msg recieved");
        }

      } while (true);

    } catch (InterruptedException ie) {

      try {
        // unsubscribe from the topic.
        client.unSubscribe(subscriptionId);
      } catch (MsgBrokerClientException e) {

        e.printStackTrace();
        System.out.println("unable to unsubscribe, ignoring");
      }

      // shutdown the consumer service.
      client.shutdownConsumerService();

      System.out.println("interrupted");

    }
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

     * @param callback
     * @return
     * @throws Exception
     */
    public Subscription createSubscription() throws Exception {
        WseMsgBrokerClient wseClient = new WseMsgBrokerClient();
        wseClient.init(brokerLoc);
        logger.debug("Starting Subscription for topic [" + topic + "]at the broker location:" + brokerLoc);
        ConsumerServer xs = new ConsumerServer(consumerServerPort, this);
        xs.start();
        String subscriptionId = wseClient.subscribe(xs.getConsumerServiceEPRs()[0], topic, null);
        logger.debug("The consumer server started on EPR" + xs.getConsumerServiceEPRs()[0]);
        Subscription subscription = new Subscription(xs, subscriptionId, topic, callback, brokerLoc);
        return subscription;
    }
View Full Code Here

Examples of org.apache.airavata.wsmg.client.WseMsgBrokerClient

            if (logger.isDebugEnabled())
                logger.debug("\n\nStopping the Messagebox for topic" + this.topic);
        }

        try {
            WseMsgBrokerClient client = new WseMsgBrokerClient();
            client.init(this.brokerURL.toString());
            client.unSubscribe(this.subscriptionId);

            MsgboxHandler msgboxHandler = new MsgboxHandler();

            logger.debug("Unsubscribing the messagebox that was destroyed," + " SubscriptionID:" + this.subscriptionId);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.