Skip to content
Advertisement

SqsListener doesn’t pick up any messages from SQS Queue

I’m trying to implement a queue through SQS for my project, sending to the queue works just fine, but receiving from the queue isn’t working at all. It seems the receiver has absolutely no connection to the queue at all

Config

@Configuration
public class SQSConfig
{
    @Value("${cloud.aws.credentials.access-key}")
    private String access;
    @Value("${cloud.aws.credentials.secret-key}")
    private String secret;

    @Value("${cloud.aws.region.static}")
    private String region;

    @Bean
    public QueueMessagingTemplate queueMessagingTemplate(AmazonSQSAsync amazonSQSAsync) {
        return new QueueMessagingTemplate(amazonSQSAsync);
    }

    @Bean
    public AmazonSQSAsync amazonSQSAsync() {
        BasicAWSCredentials creds = new BasicAWSCredentials(access,secret);

        return AmazonSQSAsyncClientBuilder
                .standard()
                .withRegion(region)
                .withCredentials(new AWSStaticCredentialsProvider(creds))
                .build();
    }
}

Consumer Method

@SqsListener(value = "AcheevGameQueue", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
    public void receive(String message) {
        System.out.println("Received Message: " + message);
    }

Maven Dependencies

<dependency>
   <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-starter</artifactId>
    <version>3.0.0-M1</version>
</dependency>
<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-messaging</artifactId>
    <version>2.4.2</version>
</dependency>
<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>aws-core</artifactId>
    <version>2.17.251</version>
</dependency>

I’ve gone through numerous Stack Overflow posts on the topic already, haven’t found a solution.

Advertisement

Answer

It turned out to be the version of the starter library. SQS isnt fully implemented in version 3.x, so I had to revert the AWS Starter to match the other at 2.4.2. Rookie mistake

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement