diff --git a/README.md b/README.md index 163572d1..afa6a6e8 100644 --- a/README.md +++ b/README.md @@ -316,6 +316,8 @@ More in-depth guides on how configure this library: queue listening without the verbosity of a custom queue listener 1. [How to write Spring Integration Tests](doc/how-to-guides/spring/spring-how-to-write-integration-tests.md): you actually want to test what you are writing right? + 1. [How to prevent listeners from starting on startup](doc/how-to-guides/spring/spring-how-to-prevent-containers-starting-on-startup.md): guide for + preventing containers from starting when the Spring application has started up. 1. [How to Start/Stop Queue Listeners](doc/how-to-guides/spring/spring-how-to-start-stop-message-listener-containers.md): guide for starting and stopping the processing of messages for specific queue listeners 1. [How to connect to multiple AWS Accounts](doc/how-to-guides/spring/spring-how-to-connect-to-multiple-aws-accounts.md): guide for listening to queues diff --git a/doc/how-to-guides/spring/spring-how-to-prevent-containers-starting-on-startup.md b/doc/how-to-guides/spring/spring-how-to-prevent-containers-starting-on-startup.md new file mode 100644 index 00000000..16cdab85 --- /dev/null +++ b/doc/how-to-guides/spring/spring-how-to-prevent-containers-starting-on-startup.md @@ -0,0 +1,27 @@ +# Spring - How to prevent Message Listener Containers starting on startup + +By default, a [DefaultMessageListenerCoordinator](../../../spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinator.java) +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](../../../spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorProperties.java) +with the configuration you desire. + + ```java + @Configuration + class MyConfiguration { + @Bean + DefaultMessageListenerCoordinatorProperties defaultMessageListenerCoordinatorProperties() { + return StaticDefaultMessageListenerContainerCoordinatorProperties.builder() + .isAutoStartContainersEnabled(false) + .build(); + } + } + ``` + +This will not work if you have supplied your +own [MessageListenerContainerCoordinator](../../../spring/spring-api/src/main/java/com/jashmore/sqs/spring/container/MessageListenerContainerCoordinator.java) +bean as the default coordinator will now not be configured for you anymore. diff --git a/spring/spring-api/src/main/java/com/jashmore/sqs/spring/container/MessageListenerContainerCoordinator.java b/spring/spring-api/src/main/java/com/jashmore/sqs/spring/container/MessageListenerContainerCoordinator.java index 8e7665c1..5082ef4c 100644 --- a/spring/spring-api/src/main/java/com/jashmore/sqs/spring/container/MessageListenerContainerCoordinator.java +++ b/spring/spring-api/src/main/java/com/jashmore/sqs/spring/container/MessageListenerContainerCoordinator.java @@ -1,10 +1,21 @@ package com.jashmore.sqs.spring.container; +import com.jashmore.sqs.container.MessageListenerContainer; + +import java.util.Set; + /** * Service that can be injected into the Spring Application to start and stop the containers that are controlling * the consumption of queue messages. */ public interface MessageListenerContainerCoordinator { + /** + * Get all of the containers that have been configured with this coordinator. + * + * @return the set of containers + */ + Set getContainers(); + /** * Start all of the containers that have been built for the application. */ diff --git a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java index 65becbc7..9fd78efc 100644 --- a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java +++ b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java @@ -15,8 +15,10 @@ import com.jashmore.sqs.spring.client.DefaultSqsAsyncClientProvider; import com.jashmore.sqs.spring.client.SqsAsyncClientProvider; import com.jashmore.sqs.spring.container.DefaultMessageListenerContainerCoordinator; +import com.jashmore.sqs.spring.container.DefaultMessageListenerContainerCoordinatorProperties; import com.jashmore.sqs.spring.container.MessageListenerContainerCoordinator; import com.jashmore.sqs.spring.container.MessageListenerContainerFactory; +import com.jashmore.sqs.spring.container.StaticDefaultMessageListenerContainerCoordinatorProperties; import com.jashmore.sqs.spring.container.basic.BasicMessageListenerContainerFactory; import com.jashmore.sqs.spring.container.prefetch.PrefetchingMessageListenerContainerFactory; import com.jashmore.sqs.spring.jackson.SqsListenerObjectMapperSupplier; @@ -174,6 +176,18 @@ public QueueResolver queueResolver(final Environment environment) { @Configuration @ConditionalOnMissingBean(MessageListenerContainerCoordinator.class) public static class QueueWrappingConfiguration { + /** + * The configuration properties for the {@link DefaultMessageListenerContainerCoordinator}. + * + * @return the default configuration properties for the coordinator + */ + @Bean + @ConditionalOnMissingBean(DefaultMessageListenerContainerCoordinatorProperties.class) + public DefaultMessageListenerContainerCoordinatorProperties defaultMessageListenerContainerCoordinatorProperties() { + return StaticDefaultMessageListenerContainerCoordinatorProperties.builder() + .isAutoStartContainersEnabled(true) + .build(); + } /** * The default {@link MessageListenerContainerCoordinator} that will be provided if it has not been overridden by the consumer. @@ -181,19 +195,22 @@ public static class QueueWrappingConfiguration { *

This will use any {@link MessageListenerContainerFactory}s defined in the spring context to wrap any bean methods with a * {@link MessageListenerContainer}. * + * @param properties the configuration properties for this coordinator * @param messageListenerContainerFactories the wrappers provided in the context * @return the default {@link MessageListenerContainerCoordinator} */ @Bean - public MessageListenerContainerCoordinator queueContainerService(final List messageListenerContainerFactories) { - return new DefaultMessageListenerContainerCoordinator(messageListenerContainerFactories); + public MessageListenerContainerCoordinator messageListenerContainerCoordinator( + final DefaultMessageListenerContainerCoordinatorProperties properties, + final List messageListenerContainerFactories) { + return new DefaultMessageListenerContainerCoordinator(properties, messageListenerContainerFactories); } /** * Contains all of the core {@link MessageListenerContainerFactory} implementations that should be enabled by default. * *

The consumer can provide any other {@link MessageListenerContainerFactory} beans in their context and these will be included in the automatic - * wrapping of the methods by the {@link #queueContainerService(List)} bean. + * wrapping of the methods by the {@link #messageListenerContainerCoordinator(DefaultMessageListenerContainerCoordinatorProperties, List)} bean. */ @Configuration public static class MessageListenerContainerFactoryConfiguration { diff --git a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinator.java b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinator.java index 31139ac3..71a6f165 100644 --- a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinator.java +++ b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinator.java @@ -3,7 +3,6 @@ import com.jashmore.documentation.annotations.GuardedBy; import com.jashmore.documentation.annotations.Nonnull; import com.jashmore.documentation.annotations.ThreadSafe; -import com.jashmore.documentation.annotations.VisibleForTesting; import com.jashmore.sqs.container.MessageListenerContainer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeansException; @@ -34,6 +33,7 @@ @Slf4j @ThreadSafe public class DefaultMessageListenerContainerCoordinator implements MessageListenerContainerCoordinator, ApplicationContextAware, SmartLifecycle { + private final DefaultMessageListenerContainerCoordinatorProperties properties; /** * These {@link MessageListenerContainerFactory}s should be injected by the spring application and therefore to add more wrappers into the * system a corresponding bean with this interface must be included in the application. @@ -57,7 +57,9 @@ public class DefaultMessageListenerContainerCoordinator implements MessageListen */ private final AtomicBoolean isRunning = new AtomicBoolean(false); - public DefaultMessageListenerContainerCoordinator(final List messageListenerContainerFactories) { + public DefaultMessageListenerContainerCoordinator(final DefaultMessageListenerContainerCoordinatorProperties properties, + final List messageListenerContainerFactories) { + this.properties = properties; this.messageListenerContainerFactories = messageListenerContainerFactories; this.containersLazilyLoadedCache = null; } @@ -69,6 +71,11 @@ public void setApplicationContext(@Nonnull final ApplicationContext applicationC } } + @Override + public Set getContainers() { + return Collections.unmodifiableSet((new HashSet<>(getContainerMap().values()))); + } + @Override public void startAllContainers() { runForAllContainers(MessageListenerContainer::start); @@ -124,7 +131,7 @@ private void runForContainer(final String containerIdentifier, final Consumer getContainers() { - return Collections.unmodifiableSet((new HashSet<>(getContainerMap().values()))); - } - /** * Get the map of container ID to containers. * diff --git a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorProperties.java b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorProperties.java new file mode 100644 index 00000000..05337ecb --- /dev/null +++ b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorProperties.java @@ -0,0 +1,12 @@ +package com.jashmore.sqs.spring.container; + +import com.jashmore.sqs.container.MessageListenerContainer; + +public interface DefaultMessageListenerContainerCoordinatorProperties { + /** + * Determine if the {@link MessageListenerContainer}s should be started up by default when the Spring Container starts up. + * + * @return whether the containers will be started on startup + */ + boolean isAutoStartContainersEnabled(); +} diff --git a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/StaticDefaultMessageListenerContainerCoordinatorProperties.java b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/StaticDefaultMessageListenerContainerCoordinatorProperties.java new file mode 100644 index 00000000..7391b1c0 --- /dev/null +++ b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/StaticDefaultMessageListenerContainerCoordinatorProperties.java @@ -0,0 +1,18 @@ +package com.jashmore.sqs.spring.container; + +import lombok.Builder; +import lombok.Value; + +/** + * Provides the properties as static values that never change. + */ +@Value +@Builder(toBuilder = true) +public class StaticDefaultMessageListenerContainerCoordinatorProperties implements DefaultMessageListenerContainerCoordinatorProperties { + boolean isAutoStartContainersEnabled; + + @Override + public boolean isAutoStartContainersEnabled() { + return isAutoStartContainersEnabled; + } +} diff --git a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java index f26cbe48..baf60966 100644 --- a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java +++ b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java @@ -3,6 +3,7 @@ import static java.util.stream.Collectors.toSet; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; import com.jashmore.sqs.argument.ArgumentResolver; @@ -15,6 +16,7 @@ import com.jashmore.sqs.argument.payload.PayloadArgumentResolver; import com.jashmore.sqs.spring.client.SqsAsyncClientProvider; import com.jashmore.sqs.spring.container.DefaultMessageListenerContainerCoordinator; +import com.jashmore.sqs.spring.container.DefaultMessageListenerContainerCoordinatorProperties; import com.jashmore.sqs.spring.container.MessageListenerContainerCoordinator; import com.jashmore.sqs.spring.container.MessageListenerContainerFactory; import com.jashmore.sqs.spring.container.basic.BasicMessageListenerContainerFactory; @@ -65,8 +67,6 @@ void whenUserProvidesSqsAsyncClientTheDefaultIsNotUsed() { @Nested class SqsAsyncClientProviderBean { - - @Test void whenNoSqsAsyncClientProviderADefaultImplementationIsCreated() { contextRunner @@ -287,6 +287,32 @@ void defaultMessageListenerContainerCoordinatorIsUsedIfUserContextDoesNotDefineI }); } + @Test + void defaultCoordinatorPropertiesWillAutoStartAllContainers() { + contextRunner + .withUserConfiguration(UserConfigurationWithSqsClient.class) + .run((context) -> { + final DefaultMessageListenerContainerCoordinatorProperties properties + = context.getBean(DefaultMessageListenerContainerCoordinatorProperties.class); + assertThat(properties.isAutoStartContainersEnabled()).isTrue(); + }); + } + + @Test + void customDefaultCoordinatorPropertiesWillOverrideDefault() { + final DefaultMessageListenerContainerCoordinatorProperties customProperties = mock(DefaultMessageListenerContainerCoordinatorProperties.class); + when(customProperties.isAutoStartContainersEnabled()).thenReturn(false); + contextRunner + .withUserConfiguration(UserConfigurationWithSqsClient.class) + .withBean(DefaultMessageListenerContainerCoordinatorProperties.class, () -> customProperties) + .run((context) -> { + final DefaultMessageListenerContainerCoordinatorProperties properties + = context.getBean(DefaultMessageListenerContainerCoordinatorProperties.class); + assertThat(properties).isSameAs(customProperties); + assertThat(context.getBean(DefaultMessageListenerContainerCoordinator.class).isAutoStartup()).isFalse(); + }); + } + @Test void allCoreDefinedMessageListenerContainerFactoriesAreIncludedInContext() { contextRunner diff --git a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorTest.java b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorTest.java index 521463f9..beecba8c 100644 --- a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorTest.java +++ b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/DefaultMessageListenerContainerCoordinatorTest.java @@ -26,6 +26,9 @@ @Slf4j @ExtendWith(MockitoExtension.class) class DefaultMessageListenerContainerCoordinatorTest { + @Mock + private DefaultMessageListenerContainerCoordinatorProperties properties; + @Mock private ApplicationContext applicationContext; @@ -33,7 +36,7 @@ class DefaultMessageListenerContainerCoordinatorTest { void whenNoMessageListenerContainerFactoriesPresentBeansAreNotProcessed() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); // act defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); @@ -48,7 +51,7 @@ void settingApplicationContextTwiceDoesNothing() { // arrange final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(applicationContext.getBeanDefinitionNames()).thenReturn(new String[] {}); // act @@ -67,7 +70,7 @@ void buildsMessageListenContainersForEachEligibleBeanMethod() throws NoSuchMetho final Method method = bean.getClass().getMethod("method"); final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(messageListenerContainerFactory.canHandleMethod(any(Method.class))).thenReturn(false); when(messageListenerContainerFactory.canHandleMethod(method)).thenReturn(true); final MessageListenerContainer container = mock(MessageListenerContainer.class); @@ -90,7 +93,7 @@ void methodsThatAreNotEligibleForWrappingWillNotCreateMessageListeners() throws final Method method = bean.getClass().getMethod("method"); final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(messageListenerContainerFactory.canHandleMethod(any(Method.class))).thenReturn(false); when(applicationContext.getBeanDefinitionNames()).thenReturn(new String[] {"bean"}); when(applicationContext.getBean("bean")).thenReturn(bean); @@ -110,7 +113,7 @@ void duplicateMessageListenerContainsThrowsExceptionWhenStarting() throws NoSuch final Method methodOne = bean.getClass().getMethod("methodOne"); final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(messageListenerContainerFactory.canHandleMethod(any(Method.class))).thenReturn(false); when(messageListenerContainerFactory.canHandleMethod(methodOne)).thenReturn(true); @@ -139,7 +142,7 @@ void startingContainersWillStartAllMessageListenerContainersBuilt() throws NoSuc final Method method = bean.getClass().getMethod("method"); final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(messageListenerContainerFactory.canHandleMethod(any(Method.class))).thenReturn(false); when(messageListenerContainerFactory.canHandleMethod(method)).thenReturn(true); final MessageListenerContainer container = mock(MessageListenerContainer.class); @@ -165,7 +168,7 @@ void stoppingAllContainersWillStopAllMessageListenerContainersBuilt() throws NoS final Method method = bean.getClass().getMethod("method"); final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(messageListenerContainerFactory.canHandleMethod(any(Method.class))).thenReturn(false); when(messageListenerContainerFactory.canHandleMethod(method)).thenReturn(true); final MessageListenerContainer container = mock(MessageListenerContainer.class); @@ -192,7 +195,7 @@ void stoppingAllContainersWillStopAllMessageListenerContainersBuilt() throws NoS void stoppingContainerThatDoesNotExistThrowsIllegalArgumentException() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); // act @@ -206,7 +209,7 @@ void stoppingIndividualContainerWithIdentifierCallsStopOnContainer() throws NoSu final Method method = bean.getClass().getMethod("method"); final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(messageListenerContainerFactory.canHandleMethod(any(Method.class))).thenReturn(false); when(messageListenerContainerFactory.canHandleMethod(method)).thenReturn(true); final MessageListenerContainer container = mock(MessageListenerContainer.class); @@ -227,7 +230,7 @@ void stoppingIndividualContainerWithIdentifierCallsStopOnContainer() throws NoSu void startingContainerThatDoesNotExistThrowsIllegalArgumentException() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); // act @@ -241,7 +244,7 @@ void startingIndividualContainerWithIdentifierCallsStopOnContainer() throws NoSu final Method method = bean.getClass().getMethod("method"); final MessageListenerContainerFactory messageListenerContainerFactory = mock(MessageListenerContainerFactory.class); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator - = new DefaultMessageListenerContainerCoordinator(Collections.singletonList(messageListenerContainerFactory)); + = new DefaultMessageListenerContainerCoordinator(properties, Collections.singletonList(messageListenerContainerFactory)); when(messageListenerContainerFactory.canHandleMethod(any(Method.class))).thenReturn(false); when(messageListenerContainerFactory.canHandleMethod(method)).thenReturn(true); final MessageListenerContainer container = mock(MessageListenerContainer.class); @@ -259,20 +262,24 @@ void startingIndividualContainerWithIdentifierCallsStopOnContainer() throws NoSu } @Test - void autoStartsService() { + void configuredPropertiesWillDetermineIfContainerIsAutostartup() { // arrange + when(properties.isAutoStartContainersEnabled()) + .thenReturn(true) + .thenReturn(false); final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); // assert assertThat(defaultMessageListenerContainerCoordinator.isAutoStartup()).isTrue(); + assertThat(defaultMessageListenerContainerCoordinator.isAutoStartup()).isFalse(); } @Test void startLifeCycleStartsAllContainers() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - spy(new DefaultMessageListenerContainerCoordinator(emptyList())); + spy(new DefaultMessageListenerContainerCoordinator(properties, emptyList())); defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); // act @@ -286,7 +293,7 @@ void startLifeCycleStartsAllContainers() { void stopLifeCycleStopsAllContainers() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - spy(new DefaultMessageListenerContainerCoordinator(emptyList())); + spy(new DefaultMessageListenerContainerCoordinator(properties, emptyList())); defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); // act @@ -300,7 +307,7 @@ void stopLifeCycleStopsAllContainers() { void stopLifeCycleWithCallbackStartsAllContainersAndRunsCallback() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - spy(new DefaultMessageListenerContainerCoordinator(emptyList())); + spy(new DefaultMessageListenerContainerCoordinator(properties, emptyList())); defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); final Runnable callback = mock(Runnable.class); @@ -316,7 +323,7 @@ void stopLifeCycleWithCallbackStartsAllContainersAndRunsCallback() { void beanIsNotRunningWhenStartIsNotCalled() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); // assert assertThat(defaultMessageListenerContainerCoordinator.isRunning()).isFalse(); @@ -326,7 +333,7 @@ void beanIsNotRunningWhenStartIsNotCalled() { void startLifeCycleSetsBeanAsRunning() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); assertThat(defaultMessageListenerContainerCoordinator.isRunning()).isFalse(); @@ -341,7 +348,7 @@ void startLifeCycleSetsBeanAsRunning() { void stopLifeCycleSetsBeanAsNotRunning() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); defaultMessageListenerContainerCoordinator.setApplicationContext(applicationContext); assertThat(defaultMessageListenerContainerCoordinator.isRunning()).isFalse(); defaultMessageListenerContainerCoordinator.start(); @@ -357,7 +364,7 @@ void stopLifeCycleSetsBeanAsNotRunning() { void beanShouldBeStartedLast() { // arrange final DefaultMessageListenerContainerCoordinator defaultMessageListenerContainerCoordinator = - new DefaultMessageListenerContainerCoordinator(emptyList()); + new DefaultMessageListenerContainerCoordinator(properties, emptyList()); // assert assertThat(defaultMessageListenerContainerCoordinator.getPhase()).isEqualTo(Integer.MAX_VALUE);