6

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?

spencergibb
  • 24,471
  • 6
  • 69
  • 75
Don_Quijote
  • 936
  • 3
  • 18
  • 27

4 Answers4

8

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

FrontierPsychiatrist
  • 1,343
  • 10
  • 20
  • 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. – Fgop Jul 19 '23 at 13:38
1

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

  • 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. – Fgop Mar 16 '23 at 16:38
0

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

sendon1982
  • 9,982
  • 61
  • 44
0

@EnableSqs

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

  • 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](/help/how-to-answer). – Community Jul 18 '23 at 12:23