Example usage for org.springframework.jms.config JmsListenerEndpointRegistry getListenerContainer

List of usage examples for org.springframework.jms.config JmsListenerEndpointRegistry getListenerContainer

Introduction

In this page you can find the example usage for org.springframework.jms.config JmsListenerEndpointRegistry getListenerContainer.

Prototype

@Nullable
public MessageListenerContainer getListenerContainer(String id) 

Source Link

Document

Return the MessageListenerContainer with the specified id or null if no such container exists.

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  a v  a 2 s .  c  om*/
@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.
 */// w w  w .j  a  v  a2 s  .c  om
@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);
    }
}