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

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

Introduction

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

Prototype

@Override
default int getPhase() 

Source Link

Document

Return the phase that this lifecycle object is supposed to run in.

Usage

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

/**
 * Create and start a new container using the specified factory.
 *///from   w w  w .j  av a  2 s .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;
}