Package org.apache.stratos.messaging.message.receiver.instance.notifier

Examples of org.apache.stratos.messaging.message.receiver.instance.notifier.InstanceNotifierEventReceiver


  protected void subscribeToTopicsAndRegisterListeners() {
    if(log.isDebugEnabled()) {
            log.debug("Starting instance notifier event message receiver thread");
        }

        InstanceNotifierEventReceiver eventReceiver = new InstanceNotifierEventReceiver();
        eventReceiver.addEventListener(new ArtifactUpdateEventListener() {
            @Override
            protected void onEvent(Event event) {
                onArtifactUpdateEvent((ArtifactUpdatedEvent) event);
            }
        });

        eventReceiver.addEventListener(new InstanceCleanupMemberEventListener() {
            @Override
            protected void onEvent(Event event) {
                String memberIdInPayload = CartridgeAgentConfiguration.getInstance().getMemberId();
                InstanceCleanupMemberEvent instanceCleanupMemberEvent = (InstanceCleanupMemberEvent) event;
                if (memberIdInPayload.equals(instanceCleanupMemberEvent.getMemberId())) {
                    onInstanceCleanupEvent();
                }
            }
        });

        eventReceiver.addEventListener(new InstanceCleanupClusterEventListener() {
            @Override
            protected void onEvent(Event event) {
                String clusterIdInPayload = CartridgeAgentConfiguration.getInstance().getClusterId();
                InstanceCleanupClusterEvent instanceCleanupClusterEvent = (InstanceCleanupClusterEvent) event;
                if (clusterIdInPayload.equals(instanceCleanupClusterEvent.getClusterId())) {
                    onInstanceCleanupEvent();
                }
            }
        });
        Thread eventReceiverThread = new Thread(eventReceiver);
        eventReceiverThread.start();

        // Wait until message receiver is subscribed to the topic to
        // send the instance started event
        while (!eventReceiver.isSubscribed())  {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.stratos.messaging.message.receiver.instance.notifier.InstanceNotifierEventReceiver

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.