Example usage for org.springframework.jms.listener MessageListenerContainer stop

List of usage examples for org.springframework.jms.listener MessageListenerContainer stop

Introduction

In this page you can find the example usage for org.springframework.jms.listener MessageListenerContainer stop.

Prototype

void stop();

Source Link

Document

Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.

Usage

From source file:org.finra.herd.service.helper.HerdJmsMessageListener.java

/**
 * Periodically check the configuration and apply the action to the herd JMS message listener service, if needed.
 *///  w ww .j  av a  2  s.co m
@Scheduled(fixedDelay = 60000)
public void controlHerdJmsMessageListener() {
    try {
        // Get the configuration setting.
        Boolean jmsMessageListenerEnabled = Boolean
                .valueOf(configurationHelper.getProperty(ConfigurationValue.JMS_LISTENER_ENABLED));

        // Get the registry bean.
        JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext().getBean(
                "org.springframework.jms.config.internalJmsListenerEndpointRegistry",
                JmsListenerEndpointRegistry.class);

        // Get the herd JMS message listener container.
        MessageListenerContainer jmsMessageListenerContainer = registry
                .getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING);

        // Get the current JMS message listener status and the configuration value.
        LOGGER.debug("controlHerdJmsMessageListener(): {}={} jmsMessageListenerContainer.isRunning()={}",
                ConfigurationValue.JMS_LISTENER_ENABLED.getKey(), jmsMessageListenerEnabled,
                jmsMessageListenerContainer.isRunning());

        // Apply the relative action if needed.
        if (!jmsMessageListenerEnabled && jmsMessageListenerContainer.isRunning()) {
            LOGGER.info("controlHerdJmsMessageListener(): Stopping the herd JMS message listener ...");
            jmsMessageListenerContainer.stop();
            LOGGER.info("controlHerdJmsMessageListener(): Done");
        } else if (jmsMessageListenerEnabled && !jmsMessageListenerContainer.isRunning()) {
            LOGGER.info("controlHerdJmsMessageListener(): Starting the herd JMS message listener ...");
            jmsMessageListenerContainer.start();
            LOGGER.info("controlHerdJmsMessageListener(): Done");
        }
    } catch (Exception e) {
        LOGGER.error(
                "controlHerdJmsMessageListener(): Failed to control the herd Jms message listener service.", e);
    }
}

From source file:org.finra.herd.service.helper.SampleDataJmsMessageListener.java

/**
 * Periodically check the configuration and apply the action to the storage policy processor JMS message listener service, if needed.
 *//*ww w. j av  a2 s  .  c o m*/
@Scheduled(fixedDelay = 60000)
public void controlSampleDataJmsMessageListener() {
    try {
        // Get the configuration setting.
        Boolean jmsMessageListenerEnabled = Boolean
                .valueOf(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED));

        // Get the registry bean.
        JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext().getBean(
                "org.springframework.jms.config.internalJmsListenerEndpointRegistry",
                JmsListenerEndpointRegistry.class);

        // Get the sample data JMS message listener container.
        MessageListenerContainer jmsMessageListenerContainer = registry
                .getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE);

        // Get the current JMS message listener status and the configuration value.
        LOGGER.debug(
                "controlStoragePolicyProcessorJmsMessageListener(): {}={} jmsMessageListenerContainer.isRunning()={}",
                ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED.getKey(), jmsMessageListenerEnabled,
                jmsMessageListenerContainer.isRunning());

        // Apply the relative action if needed.
        if (!jmsMessageListenerEnabled && jmsMessageListenerContainer.isRunning()) {
            LOGGER.info(
                    "controlSampleDataJmsMessageListener(): Stopping the sample data JMS message listener ...");
            jmsMessageListenerContainer.stop();
            LOGGER.info("controlSampleDataJmsMessageListener(): Done");
        } else if (jmsMessageListenerEnabled && !jmsMessageListenerContainer.isRunning()) {
            LOGGER.info(
                    "controlSampleDataJmsMessageListener(): Starting the sample data JMS message listener ...");
            jmsMessageListenerContainer.start();
            LOGGER.info("controlSampleDataJmsMessageListener(): Done");
        }
    } catch (Exception e) {
        LOGGER.error(
                "controlSampleDataJmsMessageListener(): Failed to control the sample data Jms message listener service.",
                e);
    }
}

From source file:org.springframework.jms.config.JmsListenerEndpointRegistry.java

@Override
public void stop() {
    for (MessageListenerContainer listenerContainer : getListenerContainers()) {
        listenerContainer.stop();
    }//from w  w w .j  a v  a 2 s.co m
}