Retrieve multiple messages from SQS

后端 未结 8 1979
逝去的感伤
逝去的感伤 2020-12-10 00:55

I have multiple messages in SQS. The following code always returns only one, even if there are dozens visible (not in flight). setMaxNumberOfMessages I th

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 01:14

    AWS API Reference Guide: Query/QueryReceiveMessage

    Due to the distributed nature of the queue, a weighted random set of machines is sampled on a ReceiveMessage call. That means only the messages on the sampled machines are returned. If the number of messages in the queue is small (less than 1000), it is likely you will get fewer messages than you requested per ReceiveMessage call. If the number of messages in the queue is extremely small, you might not receive any messages in a particular ReceiveMessage response; in which case you should repeat the request.

    and

    MaxNumberOfMessages: Maximum number of messages to return. SQS never returns more messages than this value but might return fewer.

提交回复
热议问题