AWS SQS ReceiveMessage Did you receive fewer messages than you requested?
P粉894008490
P粉894008490 2023-12-24 10:50:53
0
1
433

I have configured a simple SQS and I want to process 4 messages at once. In my testing it had 2 "available" messages. When I receive the message, it only produces 1 at a time. What did i do wrong?

sqs = boto3.client('sqs')
response = sqs.receive_message(
    QueueUrl=queue_url,
    MaxNumberOfMessages=4
)

P粉894008490
P粉894008490

reply all(1)
P粉654894952

You did nothing wrong and this behavior is normal.

This is due to the distributed nature of SQS (and most AWS services). Basically, not all nodes have all messages available, and the node you're talking to may return any number between 0 and MaxNumberOfMessages if any are available. To actually receive multiple messages in a single call, you would need to have 100 or 1000+ messages in the queue, and even then you might be out of luck and receive very few messages.

From Documentation:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!