Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Can not receive sqs message after the application has been running for a few days #742

Open
vitahlin opened this issue Dec 7, 2020 · 4 comments
Labels
component: sqs SQS integration related issue status: waiting-for-feedback We need additional information before we can continue type: bug A general bug

Comments

@vitahlin
Copy link

vitahlin commented Dec 7, 2020

Type: Bug

Component:
SQS

Describe the bug

After the application runs for a few days, listener can not receive the message and I saw the count of messages in the queue growing in the Amazon admin. The application runs normally only sqs listener not receive message. After I restart application then it worked well again.

Spring Cloud Version:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-aws-messaging</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

Sample
listener

 @SqsListener(value = "merchant", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
    public void receiveMerchantMsg(String data) throws InterruptedException, ExecutionException, IOException {
        logger.info("SQS etsy_shop begin consume, msg={}", data);
        MerchantMsgBo msg = JSON.parseObject(data, MerchantMsgBo.class);
        logger.info("SQS shop consume success, shopName={}, msg={}", msg.getShopName(), data);
    }

AwsConfig:

  @Bean
    public AmazonSQSAsync getSqsAsync(AWSStaticCredentialsProvider awsStaticCredentialsProvider) {
        return AmazonSQSAsyncClientBuilder.standard()
            .withCredentials(awsStaticCredentialsProvider)
            .withClientConfiguration(new ClientConfiguration().withConnectionTimeout(5000))
            .withRegion(Regions.CN_NORTH_1)
            .build();
    }

    @Bean
    public SimpleMessageListenerContainer simpleMessageListenerContainer(
        AmazonSQSAsync amazonSQSAsync,
        QueueMessageHandler queueMessageHandler
    ) {
        SimpleMessageListenerContainer simpleMessageListenerContainer = new SimpleMessageListenerContainer();
        simpleMessageListenerContainer.setAmazonSqs(amazonSQSAsync);
        simpleMessageListenerContainer.setMessageHandler(queueMessageHandler);
        simpleMessageListenerContainer.setMaxNumberOfMessages(10);
        simpleMessageListenerContainer.setAutoStartup(true);
        return simpleMessageListenerContainer;
    }

    @Bean
    public QueueMessageHandler queueMessageHandler(AmazonSQSAsync amazonSQSAsync) {
        QueueMessageHandlerFactory queueMessageHandlerFactory = new QueueMessageHandlerFactory();
        queueMessageHandlerFactory.setAmazonSqs(amazonSQSAsync);
        return queueMessageHandlerFactory.createQueueMessageHandler();
    }
@github-actions github-actions bot added the type: bug A general bug label Dec 7, 2020
@vitahlin vitahlin changed the title Can not receive sqs message after theapplication has been running for a period of time Can not receive sqs message after theapplication has been running for a few days Dec 7, 2020
@github-actions github-actions bot added the status: waiting-for-triage An issue we've not yet triaged label Dec 7, 2020
@vitahlin vitahlin changed the title Can not receive sqs message after theapplication has been running for a few days Can not receive sqs message after the application has been running for a few days Dec 7, 2020
@maciejwalkowiak maciejwalkowiak added the component: sqs SQS integration related issue label Jan 22, 2021
@sreekanth-tf
Copy link

Any updates, please?

@edudar
Copy link

edudar commented Jul 23, 2021

I believe I might be experiencing the same issue. In my case, it's a matter of hours. I have multiple message listener containers and some of them randomly stop receiving messages. THere are no visible exceptions or errors. They just quietly quit.

@maciejwalkowiak
Copy link
Contributor

Have you tried to use the latest version of Spring Cloud AWS 2.3.1? Please note that Spring Cloud AWS moved to https://github.com/awspring/spring-cloud-aws, docs can be found at https://docs.awspring.io/spring-cloud-aws/docs/2.3.1/reference/html/index.html

@edudar
Copy link

edudar commented Aug 15, 2021

I have not yet. It’s the plan but the move between packages made this a little bit bigger of a deal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: sqs SQS integration related issue status: waiting-for-feedback We need additional information before we can continue type: bug A general bug
Development

No branches or pull requests

4 participants