Example usage for org.springframework.jms.config JmsListenerContainerFactory createListenerContainer

List of usage examples for org.springframework.jms.config JmsListenerContainerFactory createListenerContainer

Introduction

In this page you can find the example usage for org.springframework.jms.config JmsListenerContainerFactory createListenerContainer.

Prototype

C createListenerContainer(JmsListenerEndpoint endpoint);

Source Link

Document

Create a MessageListenerContainer for the given JmsListenerEndpoint .

Usage

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

/**
 * Create and start a new container using the specified factory.
 *///ww w . ja v a 2s. c o m
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint,
        JmsListenerContainerFactory<?> factory) {

    MessageListenerContainer listenerContainer = factory.createListenerContainer(endpoint);

    if (listenerContainer instanceof InitializingBean) {
        try {
            ((InitializingBean) listenerContainer).afterPropertiesSet();
        } catch (Exception ex) {
            throw new BeanInitializationException("Failed to initialize message listener container", ex);
        }
    }

    int containerPhase = listenerContainer.getPhase();
    if (containerPhase < Integer.MAX_VALUE) { // a custom phase value
        if (this.phase < Integer.MAX_VALUE && this.phase != containerPhase) {
            throw new IllegalStateException("Encountered phase mismatch between container factory definitions: "
                    + this.phase + " vs " + containerPhase);
        }
        this.phase = listenerContainer.getPhase();
    }

    return listenerContainer;
}