Package org.apache.airavata.workflow.tracking.client

Examples of org.apache.airavata.workflow.tracking.client.Subscription


    }

    private boolean wait = true;

    public void testMessagePulling() throws Exception {
        Subscription subscription = null;

        Callback testCallback1 = new Callback() {
            public void deliverMessage(String topic, NotificationType type, XmlObject messageObj) {
                System.out.println("Notification Received, notification of type:" + type);
                // assertEquals(type, NotificationType.WorkflowInitialized);
                wait = false;
            }
        };

        subscription = LeadNotificationManager.createMessageBoxSubscription(MESSAGEBOX_URL, BROKER_URL, TEST_TOPIC,
                null, testCallback1);

        System.out.println(subscription.getMessageBoxEPR());
        System.out.println(subscription.getSubscriptionID());

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

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

        client.publish(TEST_TOPIC, msg);

        EndpointReference MSG_BOX_EPR = subscription.getMessageBoxEPR();
        System.out.println(MSG_BOX_EPR);
        String subscriptionID = subscription.getSubscriptionID();
        Callback testCallback2 = new Callback() {

            public void deliverMessage(String topic, NotificationType type, XmlObject messageObj) {

                System.out.println("Notification Received, notification of type:" + type);
                // This assertion is wrong because type and NotificationType.WorkflowInitialized are two different types
                // assertEquals(type, NotificationType.WorkflowInitialized);
                wait = false;

            }
        };
        subscription = LeadNotificationManager.startListeningToSavedSubscription(BROKER_URL, MSG_BOX_EPR,
                subscriptionID, TEST_TOPIC, null, testCallback2, true);

        System.out.println(subscription.getMessageBoxEPR());

        while (wait) {

            Thread.sleep(1000);

        }

        System.out.println("MessagePuller test completed");
        subscription.destroy();
    }
View Full Code Here


    public void tearDown() throws Exception {
    }

    @Test
    public void testRenewSubscription() throws Exception {
        Subscription sub = LeadNotificationManager.createMessageBoxSubscription(MESSAGEBOX_URL, BROKER_URL, TOPIC,
                null, this, false);

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

        OMElement msg = OMAbstractFactory.getOMFactory().createOMElement("test", null);
        msg.setText("mustwork");
        client.publish(TOPIC, msg);
        // sub.destroy();

        msg.setText("destroyed");
        client.publish(TOPIC, msg);
        Subscription sub2 = LeadNotificationManager.renewMessageboxSubscription(BROKER_URL, sub.getMessageBoxEPR(),
                sub.getSubscriptionID(), TOPIC, null, false);

        msg.setText("mustworkagain");
        client.publish(TOPIC, msg);

        System.out.println(sub2.getSubscriptionID());
        while (counter < 2) {
            Thread.sleep(1000);
        }
        Thread.sleep(10000);
    }
View Full Code Here

        TestMsgCallback c1 = new TestMsgCallback(repetition);
        TestMsgCallback c2 = new TestMsgCallback(repetition);

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

        System.out.println(b1);
        System.out.println(b2);

        subscription.destroy();
        subscription2.destroy();

    }
View Full Code Here

        TestMsgCallback c1 = new TestMsgCallback(repetition);
        TestMsgCallback c2 = new TestMsgCallback(repetition);

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

        System.out.println(b1);
        System.out.println(b2);

        subscription2.destroy();
        subscription.destroy();
    }
View Full Code Here

    }

    @Override
    public void run() {
        Subscription subscription = null;
        try {
            subscription = LeadNotificationManager.createMessageBoxSubscription(this.messageboxLocation,
                    this.brokerLocation, this.topic, null, new Callback() {

                        public void deliverMessage(String topic, NotificationType type, XmlObject messageObj) {
View Full Code Here

    public void tearDown() throws Exception {
    }

    @Test
    public void testRestart() throws Exception {
        Subscription subscription = null;

        MessageBoxCreateThread thread = new MessageBoxCreateThread(BROKER_URL, MESSAGEBOX_URL, TOPIC);
        thread.start();

        Thread.sleep(100);
        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();
        String topic = thread.getTopic();
        System.out.println(epr);
        System.out.println(subscriptionID);

        subscription = LeadNotificationManager.startListeningToSavedSubscription(BROKER_URL, epr, subscriptionID,
                topic, null, new Callback() {

                    public void deliverMessage(String topic, NotificationType type, XmlObject messageObj) {

                        System.out.println("Notification Received, notification of type:" + type);
                        System.out.println("Topic[" + topic + "]");
                        // assertEquals(type, NotificationType.WorkflowInitialized);
                        wait = false;

                    }
                }, false);

        System.out.println(subscription.getMessageBoxEPR());

        while (wait) {
            Thread.sleep(1000);

        }
View Full Code Here

        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

            endpointReference = EndpointReferenceHelper.fromString(epr);
        } catch (AxisFault f) {
            throw new MsgBrokerClientException("unable to convert end point reference", f);
        }
        subscriptionId = subscribeToBroker(endpointReference.getAddress(), topic, xpath, wseClient, subscribePermanatly);
        Subscription subscription = new Subscription(this, subscriptionId, topic, callback, this.brokerURL);
        subscription.setMessageBoxEpr(endpointReference);
        return subscription;
    }
View Full Code Here

        this.topic = topic;
        WseMsgBrokerClient wseClient = new WseMsgBrokerClient();
        logger.debug("\n\nCreate Subscription for topic" + topic + " [Messagebox]\n\n");

        subscriptionId = subscribeToBroker(endpointReference.getAddress(), topic, xpath, wseClient, subscribePermanatly);
        Subscription subscription = new Subscription(this, subscriptionId, topic, callback, this.brokerURL);
        subscription.setMessageBoxEpr(endpointReference);
        return subscription;
    }
View Full Code Here

            formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId);

        }

        subscriptionId = subscribeToBroker(formattedEventSink, topic, xpath, wseClient, subscribePermanatly);
        Subscription subscription = new Subscription(this, subscriptionId, topic, callback, this.brokerURL);
        subscription.setMessageBoxEpr(msgBoxAddr);
        return subscription;

    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.workflow.tracking.client.Subscription

Copyright © 2018 www.massapicom. 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.