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.
-
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.