springspring-cloudamazon-sqsspring-jmsspring-cloud-aws

AWS SQS and Spring pollTimeoutSeconds difference


I hava been reading about using pollTimeoutSeconds in @SqsListener from Spring Cloud AWS.

Look at this configuration:

@SqsListener(value = "my-queue", pollTimeoutSeconds = "10", maxMessagesPerPoll = "1", maxConcurrentMessages = "1")

Reading the documentation I understood that: If a message arrives within 10 seconds, it's immediately processed. I did the test and confirmed this.

I understood that for every 10 seconds, a new pool will be started again. I could see that on CloudWatch Graphic.

The only difference is that using 1s a request will be fired every 1s, with 10s the request will wait for 10s. (more requests, more costs)

My question is: in terms of receiving messages there is no difference between 10 or 1 second, messages will always be processed immediately when they become visible in SQS, is that correct?


Solution

  • messages will always be processed immediately when they become visible in SQS, is that correct?

    Immediately is a strong word, but for simplicity, I would say yes.

    If a client has started polling and a message enters the queue, SQS will send a response back to client with this message. pollTimeoutSeconds does not affect response time. If a message is available, the call returns sooner than pollTimeoutSeconds

    pollTimeoutSeconds is a same thing as WaitTimeSeconds parameter of ReceiveMessage request. About them you could read here: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html