Reputation: 95
Currently, we have an SQS client configured using an IAM Role that is picked up on the cluster. However, migrating over to Springboot 3 the @SqsListener is no longer consuming the messages.
NOTE: Same code, works on Springboot 2, but not on Springboot 3 is there something else that needs to be configured or am I missing something?
Anyone else run into this issue?
Upvotes: 5
Views: 18928
Reputation: 9
@EnableSqs
add this annotation in the class where you are using @SqsListener
in spring boot 3
Upvotes: 0
Reputation: 803
SQS message listener with spring boot 3
Add following in pom.xml
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-starter-sqs</artifactId>
</dependency>
<!-- Use BOM provided by spring for version managament -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-dependencies</artifactId>
<version>3.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Working example: https://github.com/raovikash/sqs-listener-spring-boot3
Upvotes: 6
Reputation: 21
In order for the @SqsListener
annotation to work, the dependency spring-cloud-aws-autoconfigure is required - this autowires the containers etc. needed for the annotation to function. You can see the extra stuff it autowires here.
Upvotes: 2
Reputation: 97
Spring Boot 3.0x requires Spring Cloud AWS 3.0x and AWS Java SDK 2.x
Visit this link for info
In order to create a Consumer in Spring Boot 3.0, you need to use @EnableScheduling
Bean in your main application. Then you need to use @Scheduled(fixedDelay = 5000)
above the receive method. @Scheduled bean replaces the @SqsListener here. You can visit this link for more info.
Upvotes: 2
Reputation: 2584
Spring Cloud AWS 2.x is only compatible with Spring Boot 2.x, for Spring Boot 3.x, Spring Cloud AWS 3.0 is necessary.
See compatibility here.
The 3.0 RC version has just been released, feel free to try it out and provide feedback!
Upvotes: 4