diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc
index b4f15e23a..43f07dd43 100644
--- a/docs/src/main/asciidoc/_configprops.adoc
+++ b/docs/src/main/asciidoc/_configprops.adoc
@@ -93,6 +93,7 @@
|spring.cloud.aws.sqs.dualstack-enabled | | Configure whether the AWS client should use the AWS dualstack endpoint. Note that not each AWS service supports dual-stack. For complete list check AWS services that support IPv6
|spring.cloud.aws.sqs.enabled | `+++true+++` | Enables SQS integration.
|spring.cloud.aws.sqs.endpoint | | Overrides the default endpoint.
+|spring.cloud.aws.sqs.listener.auto-startup | | Configure whether SQS listeners are started automatically or not. If set to false, the listener containers need to be started manually.
|spring.cloud.aws.sqs.listener.max-concurrent-messages | | The maximum concurrent messages that can be processed simultaneously for each queue. Note that if acknowledgement batching is being used, the actual maximum number of messages inflight might be higher.
|spring.cloud.aws.sqs.listener.max-delay-between-polls | | The maximum amount of time to wait between consecutive polls to SQS.
|spring.cloud.aws.sqs.listener.max-messages-per-poll | | The maximum number of messages to be retrieved in a single poll to SQS.
@@ -100,4 +101,4 @@
|spring.cloud.aws.sqs.queue-not-found-strategy | |
|spring.cloud.aws.sqs.region | | Overrides the default region.
-|===
\ No newline at end of file
+|===
diff --git a/docs/src/main/asciidoc/sqs.adoc b/docs/src/main/asciidoc/sqs.adoc
index 8e259f297..a0f1bb61b 100644
--- a/docs/src/main/asciidoc/sqs.adoc
+++ b/docs/src/main/asciidoc/sqs.adoc
@@ -874,6 +874,7 @@ The Spring Boot Starter for SQS provides the following auto-configuration proper
| <> | Maximum number of messages to be received per poll. | No | 10
| <> | Maximum amount of time to wait for messages in a poll. | No | 10 seconds
| <> | Maximum amount of time to wait between polls. | No | 10 seconds
+| `spring.cloud.aws.sqs.listener.auto-startup` | Defines whether SQS listeners are started automatically or not. | No | true
| `spring.cloud.aws.sqs.queue-not-found-strategy` | The strategy to be used by SqsTemplate and SqsListeners when a queue does not exist. | No | CREATE
| `spring.cloud.aws.sqs.observation-enabled` | Enables observability support for SQS operations. | No | false
|===
diff --git a/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfiguration.java b/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfiguration.java
index 4eb085678..d529de1ef 100644
--- a/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfiguration.java
+++ b/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfiguration.java
@@ -156,6 +156,7 @@ private void configureProperties(SqsContainerOptionsBuilder options) {
mapper.from(this.sqsProperties.getListener().getMaxMessagesPerPoll()).to(options::maxMessagesPerPoll);
mapper.from(this.sqsProperties.getListener().getPollTimeout()).to(options::pollTimeout);
mapper.from(this.sqsProperties.getListener().getMaxDelayBetweenPolls()).to(options::maxDelayBetweenPolls);
+ mapper.from(this.sqsProperties.getListener().getAutoStartup()).to(options::autoStartup);
}
@Bean
diff --git a/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsProperties.java b/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsProperties.java
index fdbaa4ed5..aafbe9daa 100644
--- a/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsProperties.java
+++ b/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sqs/SqsProperties.java
@@ -103,6 +103,12 @@ public static class Listener {
@Nullable
private Duration maxDelayBetweenPolls;
+ /**
+ * Defines whether SQS listeners will start automatically or not.
+ */
+ @Nullable
+ private Boolean autoStartup;
+
@Nullable
public Integer getMaxConcurrentMessages() {
return this.maxConcurrentMessages;
@@ -138,6 +144,15 @@ public Duration getMaxDelayBetweenPolls() {
public void setMaxDelayBetweenPolls(Duration maxDelayBetweenPolls) {
this.maxDelayBetweenPolls = maxDelayBetweenPolls;
}
+
+ @Nullable
+ public Boolean getAutoStartup() {
+ return autoStartup;
+ }
+
+ public void setAutoStartup(Boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
}
}
diff --git a/spring-cloud-aws-autoconfigure/src/test/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfigurationTest.java b/spring-cloud-aws-autoconfigure/src/test/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfigurationTest.java
index 83fb77bb0..5c176a7d3 100644
--- a/spring-cloud-aws-autoconfigure/src/test/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfigurationTest.java
+++ b/spring-cloud-aws-autoconfigure/src/test/java/io/awspring/cloud/autoconfigure/sqs/SqsAutoConfigurationTest.java
@@ -237,7 +237,8 @@ void configuresFactoryComponentsAndOptions() {
"spring.cloud.aws.sqs.listener.max-concurrent-messages:19",
"spring.cloud.aws.sqs.listener.max-messages-per-poll:8",
"spring.cloud.aws.sqs.listener.poll-timeout:6s",
- "spring.cloud.aws.sqs.listener.max-delay-between-polls:15s")
+ "spring.cloud.aws.sqs.listener.max-delay-between-polls:15s",
+ "spring.cloud.aws.sqs.listener.auto-startup=false")
.withUserConfiguration(CustomComponentsConfiguration.class, ObjectMapperConfiguration.class).run(context -> {
assertThat(context).hasSingleBean(SqsMessageListenerContainerFactory.class);
SqsMessageListenerContainerFactory> factory = context
@@ -254,6 +255,7 @@ void configuresFactoryComponentsAndOptions() {
assertThat(options.getMaxMessagesPerPoll()).isEqualTo(8);
assertThat(options.getPollTimeout()).isEqualTo(Duration.ofSeconds(6));
assertThat(options.getMaxDelayBetweenPolls()).isEqualTo(Duration.ofSeconds(15));
+ assertThat(options.isAutoStartup()).isEqualTo(false);
})
.extracting("messageConverter")
.asInstanceOf(type(SqsMessagingMessageConverter.class))
@@ -282,6 +284,7 @@ void configuresFactoryComponentsAndOptionsWithDefaults() {
assertThat(options.getMaxMessagesPerPoll()).isEqualTo(10);
assertThat(options.getPollTimeout()).isEqualTo(Duration.ofSeconds(10));
assertThat(options.getMaxDelayBetweenPolls()).isEqualTo(Duration.ofSeconds(10));
+ assertThat(options.isAutoStartup()).isTrue();
})
.extracting("messageConverter")
.asInstanceOf(type(SqsMessagingMessageConverter.class))