Examples of WseMsgBrokerClient


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

            int consumerPort = TestUtilServer.getAvailablePort();

            String brokerEPR = "http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService";

            WseMsgBrokerClient wseMsgBrokerClient = new WseMsgBrokerClient();
            wseMsgBrokerClient.init(brokerEPR);

            String[] consumerEPRs = wseMsgBrokerClient.startConsumerService(consumerPort, this);

            assertTrue(consumerEPRs.length > 0);

            String xpathExpression = "/c/b/a";
            String topicExpression = "XpathAndTopicTestWse";

            String subscriptionID = wseMsgBrokerClient.subscribe(consumerEPRs[0], topicExpression, xpathExpression);

            try {

                wseMsgBrokerClient.publish(topicExpression, AXIOMUtil.stringToOM(validMsg));
                wseMsgBrokerClient.publish(topicExpression, AXIOMUtil.stringToOM(invalidMsg));

                SOAPEnvelope env = getMsgQueue().take();

                assertNotNull(env.getBody());
                assertNotNull(env.getBody().getChildrenWithLocalName("c"));

                OMElement element = (OMElement) env.getBody().getChildrenWithLocalName("c").next();

                String text = element.toStringWithConsume();

                assertTrue("round trip of message failed" + " - due to invalid messege content",
                        text.indexOf(new Long(value).toString()) > 0);

                Thread.sleep(5000);

                assertTrue("unexpected msg recieved", getMsgQueue().isEmpty());

            } catch (InterruptedException e) {
                fail("interrupted while waiting for message");
            } catch (XMLStreamException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                fail("invalid xml recieved: " + e.getMessage());
            }

            wseMsgBrokerClient.unSubscribe(subscriptionID);
            wseMsgBrokerClient.shutdownConsumerService();

        } catch (AxisFault e) {
            e.printStackTrace();
            fail("unexpected exception occured");
        }
View Full Code Here

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

            String invalidMsg = String.format(invalidMsgFormat, value);

            int consumerPort = TestUtilServer.getAvailablePort();

            String brokerEPR = "http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService";
            WseMsgBrokerClient msgBrokerClient = new WseMsgBrokerClient();
            msgBrokerClient.init(brokerEPR);

            String[] consumerEPRs = msgBrokerClient.startConsumerService(consumerPort, this);

            assertTrue(consumerEPRs.length > 0);

            String xpathExpression = "/c/b/a";

            String subscriptionID = msgBrokerClient.subscribe(consumerEPRs[0], null, xpathExpression);

            try {
                msgBrokerClient.publish(null, AXIOMUtil.stringToOM(validMsg));
                msgBrokerClient.publish(null, AXIOMUtil.stringToOM(invalidMsg));

                SOAPEnvelope env = getMsgQueue().take();

                assertNotNull(env.getBody());
                assertNotNull(env.getBody().getChildrenWithLocalName("c"));

                OMElement element = (OMElement) env.getBody().getChildrenWithLocalName("c").next();

                String text = element.toStringWithConsume();

                assertTrue("round trip of message failed" + " - due to invalid messege content",
                        text.indexOf(new Long(value).toString()) > 0);

                Thread.sleep(5000);

                assertTrue("unexpected msg recieved", getMsgQueue().isEmpty());

            } catch (InterruptedException e) {
                fail("interrupted while waiting for message");
            } catch (XMLStreamException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                fail("invalid xml recieved: " + e.getMessage());
            }

            msgBrokerClient.unSubscribe(subscriptionID);
            msgBrokerClient.shutdownConsumerService();

        } catch (AxisFault e) {
            e.printStackTrace();
            fail("unexpected exception occured");
        }
View Full Code Here

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

    }

    public void destroy() throws RemoteException {
        if (this.xs != null) {
            xs.stop();
            WseMsgBrokerClient client = new WseMsgBrokerClient();
            client.init(this.brokerURL);
            try {
                client.unSubscribe(this.subscriptionID);
            } catch (MsgBrokerClientException e) {
                logger.error("axisFault occured on unsubscribing subscription ID :" + this.subscriptionID, e);
                e.printStackTrace();
            }
        } else if (this.messageBoxNotificationHandler != null) {
View Full Code Here

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

        .getProperty(ConfigKeys.BROKER_EVENTING_SERVICE_EPR);

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

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

    try {

      long count = 0;
      while (true) {
        UUID uuid = UUID.randomUUID();
        count++;
        OMElement omMsg = MsgUtil.createMsg(count, getName(), uuid
            .toString());
        //MsgUtil.print("seding msg", omMsg);
        client.publish(topicExpression, omMsg);

        TimeUnit.SECONDS
            .sleep(getRandomSleepTime(timeIntervalUpperLimit));
      }
View Full Code Here

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

    String[] consumerEprs = null;

    String subscriptionId = null;

    WseMsgBrokerClient client = new WseMsgBrokerClient();
    client.init(brokerLocation);
    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], topic, null);
      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();

        try {
          OMElement msg = env.getBody().getFirstElement();

          numberOfMsgRecieved.incrementAndGet();

           System.out .println(String.format(
           "consumer [%s] recieved: %s", getName(),
           numberOfMsgRecieved));
        } 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

            System.out.println("unable to load configuration file, "
                    + "default settings will be used");
        }

        WseMsgBrokerClient brokerClient = new WseMsgBrokerClient();
        String brokerLocation = configurations.getProperty(ConfigKeys.MSGBROKER_SERVICE_URL);
        brokerClient.init(brokerLocation);
        String topic = configurations.getProperty(ConfigKeys.TOPIC);
        NotificationSender sender = new NotificationSender(brokerLocation, topic);
        // Creating a messagebox
        EndpointReference msgBoxEpr = brokerClient.createPullMsgBox(configurations.getProperty(ConfigKeys.MSGBOX_SERVICE_URL));

        // subscribing to the above created messsage box with configured topic
        String subscriptionID = brokerClient.subscribe(msgBoxEpr.getAddress(), topic, null);


        //Start the messagePuller to pull messages from newly created messagebox
        MessagePuller puller = brokerClient.startPullingEventsFromMsgBox(msgBoxEpr, new Listener(), 1000L, 2000L);

        sender.workflowStarted("Workflow Started");
        //Here we simply assume the workflow invocation is the invoke of the subscribe operation of EventingService and result
        // Is considered as the subscriptionID got from subscribe operation
        String workflowResult = subscriptionID;
        sender.workflowFinished(workflowResult);

        try {
            Thread.sleep(10000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        brokerClient.unSubscribe(subscriptionID);
        puller.stopPulling();
        System.out.println("Delete message box response :  "
                + brokerClient.deleteMsgBox(msgBoxEpr, 500L));

    }
View Full Code Here

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

        this.brokerURL = configuration.getBrokerURL();
        this.topic = configuration.getTopic();
        this.pullMode = configuration.isPullMode();
        this.messageBoxURL = configuration.getMessageBoxURL();

        this.wseClient = new WseMsgBrokerClient();
        this.wseClient.init(this.brokerURL.toString());
    }
View Full Code Here

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

    @Test
    public void WorkflowTrackingtest() throws Exception{
        logger.info("Running WorkflowTrackingTest...");
        setUp();
        Properties configurations = new Properties(getDefaults());
        WseMsgBrokerClient brokerClient = new WseMsgBrokerClient();
        String brokerLocation = "http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService";
        brokerClient.init(brokerLocation);
        String topic = configurations.getProperty(ConfigKeys.TOPIC);
        NotificationSender sender = null;
        sender = new NotificationSender(brokerLocation, topic);

        int consumerPort = TestUtilServer.getAvailablePort();

            String[] consumerEPRs = brokerClient.startConsumerService(consumerPort, this);
        // subscribing to the above created messsage box with configured topic
        String subscriptionID = brokerClient.subscribe(consumerEPRs[0], topic, null);

        sender.workflowStarted("Workflow Started");

        //Here we simply assume the workflow invocation is the invoke of the subscribe operation of EventingService and result
        // Is considered as the subscriptionID got from subscribe operation
        try {
            Thread.sleep(10000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        brokerClient.unSubscribe(subscriptionID);
        Assert.assertEquals(brokerLocation,"http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService");
        tearDown();
    }
View Full Code Here

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

            String brokerEPR = "http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService";
            long value = System.currentTimeMillis();
            String msg = String.format("<msg> current time is : %d </msg>", value);

            WseMsgBrokerClient wseMsgBrokerClient = new WseMsgBrokerClient();
            wseMsgBrokerClient.init(brokerEPR);
            int consumerPort = TestUtilServer.getAvailablePort();

            String[] consumerEPRs = wseMsgBrokerClient.startConsumerService(consumerPort, this);

            assertTrue(consumerEPRs.length > 0);

            String topic = "WseRoundTripTestTopic";

            String subscriptionID = wseMsgBrokerClient.subscribe(consumerEPRs[0], topic, null);
            System.out.println("topic sub id = " + subscriptionID);

            try {
                wseMsgBrokerClient.publish(topic, msg);
                wseMsgBrokerClient.publish(topic, AXIOMUtil.stringToOM("<foo><bar>Test</bar></foo>"));
            } catch (Exception e) {
                fail(e.getMessage());
            }

            Thread.sleep(2000);

            try {
                wseMsgBrokerClient.unSubscribe(subscriptionID);
            } catch (AxisFault e) {
                e.printStackTrace();
                fail(e.getMessage());
            }
            wseMsgBrokerClient.shutdownConsumerService();

        } catch (AxisFault e) {
            e.printStackTrace();
            try {
                System.in.read();
View Full Code Here

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

        this.brokerURL = configuration.getBrokerURL();
        this.topic = configuration.getTopic();
        this.pullMode = configuration.isPullMode();
        this.messageBoxURL = configuration.getMessageBoxURL();

        this.wseClient = new WseMsgBrokerClient();
        this.wseClient.init(this.brokerURL.toString());
    }
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.