Example usage for org.springframework.jms.listener DefaultMessageListenerContainer shutdown

List of usage examples for org.springframework.jms.listener DefaultMessageListenerContainer shutdown

Introduction

In this page you can find the example usage for org.springframework.jms.listener DefaultMessageListenerContainer shutdown.

Prototype

public void shutdown() throws JmsException 

Source Link

Document

Stop the shared Connection, call #doShutdown() , and close this container.

Usage

From source file:samples.jms.AbstractMessagingTests.java

/**
 * Shutdown gracefully at the end of the test to avoid an ugly exception.
 * Doing it explicitly avoids that. This method automatically runs after all
 * tests and must be static.//from   www .  j  a  v a2  s.  com
 */
@AfterClass
public static void shutdown() {

    Map<String, DefaultMessageListenerContainer> ctrs = applicationContext
            .getBeansOfType(DefaultMessageListenerContainer.class);

    LoggerFactory.getLogger(AbstractMessagingTests.class)
            .info("Shutting down " + ctrs.size() + " message listener container(s).");

    for (DefaultMessageListenerContainer ctr : ctrs.values())
        ctr.shutdown();
}

From source file:org.nebulaframework.grid.cluster.manager.support.CleanUpSupport.java

/**
 * Creates and returns a {@link ServiceHookCallback} which shutdowns the given
 * container and removes the given queue from broker.
 * /*from w  ww  .  j  ava  2 s  .  c o  m*/
 * @param queueName Queue to be removed
 * @param container Container to be shutdown (can be {@code null})
 * 
 * @return ServiceHookCallback
 */
private static ServiceHookCallback createRemoveQueueCallback(final String queueName,
        final DefaultMessageListenerContainer container) {
    ServiceHookCallback callback = new ServiceHookCallback() {
        public void onServiceEvent(ServiceMessage message) {
            if (container != null)
                container.shutdown();
            JMSResourceSupport.removeQueue(queueName);
        }

    };
    return callback;
}

From source file:org.nebulaframework.grid.cluster.manager.support.CleanUpSupport.java

/**
 * Creates and returns a {@link ServiceHookCallback} which shutdowns the given
 * container./*from w  w w.j a  v a  2  s  .  co m*/
 * 
 * @param container Container to be shutdown
 * 
 * @return ServiceHookCallback
 */
private static ServiceHookCallback createShutdownContainerCallback(
        final DefaultMessageListenerContainer container) {
    ServiceHookCallback callback = new ServiceHookCallback() {

        public void onServiceEvent(ServiceMessage message) {
            try {
                if (container != null)
                    container.shutdown();
            } catch (JmsException e) {
                log.debug("Unable to shutdown container", e);
            }
        }

    };
    return callback;
}

From source file:terrastore.event.impl.ActiveMQEventBus.java

@Override
public void shutdown() {
    if (!shutdown) {
        stateLock.lock();/*from   w  w w  .j a  v a  2s  . c o m*/
        try {
            for (DefaultMessageListenerContainer consumer : consumers.values()) {
                consumer.shutdown();
            }
            shutdown = true;
        } finally {
            stateLock.unlock();
        }
    } else {
        throw new IllegalStateException("The bus has been shutdown!");
    }
}

From source file:ch.algotrader.service.SubscriptionServiceImpl.java

private void updateMessageSelector(final DefaultMessageListenerContainer genericMessageListenerContainer,
        String messageSelector) {

    genericMessageListenerContainer.setMessageSelector(messageSelector);

    // restart the container (must do this in a separate thread to prevent dead-locks)
    (new Thread() {
        @Override/*  w ww. j  a  v  a 2s  .  c om*/
        public void run() {
            genericMessageListenerContainer.stop();
            genericMessageListenerContainer.shutdown();
            genericMessageListenerContainer.start();
            genericMessageListenerContainer.initialize();
        }
    }).start();
}