Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 1.34 KB

spring-how-to-prevent-containers-starting-on-startup.md

File metadata and controls

27 lines (20 loc) · 1.34 KB

Spring - How to prevent Message Listener Containers starting on startup

By default, a DefaultMessageListenerCoordinator is configured to discover containers as well as start and stop the containers in the Spring Lifecycle. This will auto startup the containers by default but, if this is not desirable, you can supply your own properties to disable this functionality.

Steps

  1. Define your own DefaultMessageListenerCoordinatorProperties with the configuration you desire.

    @Configuration
    class MyConfiguration {
    
        @Bean
        DefaultMessageListenerCoordinatorProperties defaultMessageListenerCoordinatorProperties() {
            return StaticDefaultMessageListenerContainerCoordinatorProperties.builder().isAutoStartContainersEnabled(false).build();
        }
    }

This will not work if you have supplied your own MessageListenerContainerCoordinator bean as the default coordinator will now not be configured for you anymore.