Which Spring Cloud AWS version should be used with Spring Boot 3?
Asked Answered
O

5

8

I am trying to make SqsListener work but I can't with Spring Boot 3, it simply doesn't receive anything. When I change Spring Boot version back to 2.X everything's work perfectly. I am using 2.4.2 version of Spring cloud:

...
    <dependency>
            <groupId>io.awspring.cloud</groupId>
            <artifactId>spring-cloud-starter-aws-messaging</artifactId>
        </dependency>
</dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.awspring.cloud</groupId>
                <artifactId>spring-cloud-aws-dependencies</artifactId>
                <version>2.4.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

Can you please point me to the correct version of spring cloud? Would I need to use milestone version for that?

Oshea answered 19/12, 2022 at 14:41 Comment(2)
Should be 2022.0.0-RC2 Take a look at start.spring.ioBred
Spring Cloud AWS is not part of the spring cloud release train. So 2022.0.0 is not the right answer and I'm not sure what isPorphyritic
C
9

It doesn't work as version 2.4.2 of spring-cloud-starter-aws-messaging relies on spring.factories for Spring Boot autoconfiguration, but the support for that has been removed in Spring Boot 3.0.0. See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files.

You can enable the auto configuration by creating the following file

src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

# content
io.awspring.cloud.autoconfigure.messaging.SqsAutoConfiguration

But, it probably won't work anyway as spring-cloud-aws also relies on classes from Spring Messaging that were deprecated and removed in Spring 6 (which is used in Spring Boot 3), specifically org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver.

You'll have to wait for Spring Cloud AWS to support Spring Boot 3. They are working on Spring Cloud AWS 3.0.0, but I don't think it has a release date yet. https://github.com/awspring/spring-cloud-aws

Caracole answered 5/1, 2023 at 11:53 Comment(1)
Thanks for this answer. It should be noted that since then spring-cloud-aws officially released v3 of their project. For me that fixed issues with receiving SQS messages using Spring Boot 3.Muniments
U
5

cloud-aws` release here: https://github.com/awspring/spring-cloud-aws

So spring-cloud-aws should use 3.0.x with Spring Boot 3.0.x

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

Compatibility with Spring Projects

Unsung answered 30/5, 2023 at 11:19 Comment(0)
B
3

I got this to work (Spring Boot 3.0.4 and AWS SqsListener). I cobbled together a bunch of different postings and articles. I think this is the solution really:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-messaging</artifactId>
        <version>5.3.25</version>
    </dependency>

I got really frustrated finding an end to end solution for it so I put this out on GitHub. Hopefully it helps someone else but this seems to move fast in ten different directions at once.

https://github.com/thomashcampbell/SpringBootSQSExample

Beebread answered 12/3, 2023 at 6:28 Comment(1)
Combining this tip with the accepted answer, i.e. adding the auto configuration imports file, ensures that the auto-configuration parameters like AWS region etc. are actually respected. Not sure if that workaround is production-ready by any means, but it's enough for prototypting.Muniments
S
0

@EnableSqs

add this annotation in the class where you are using @SqsListener in spring boot 3

Seismology answered 13/7, 2023 at 5:9 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Gutta
W
0

Finally I got the issue , you should get the @SqsListener annotation from the following dependency

implementation 'io.awspring.cloud:spring-cloud-aws-starter-sqs:3.1.1'

and add the dependency bom

implementation 'io.awspring.cloud:spring-cloud-aws-dependencies:3.1.1'

and if you had any SimpleMessageListener bean config for max messages, poll time...

please pass it in the annotation @SqsListener itself

Whimper answered 14/6 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.