接收最多 10 条消息时为 SQS 设置可见性超时
Setting visibility timeout for SQS when receiving up to 10 messages
ReceiveMessage
调用可以 return 来自队列 (http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html) 的最多 10 条消息。我正在使用长轮询。
我将遍历收到的消息列表并在单个线程中处理它们。这是否意味着我应该将队列的 VisibilityTimeout
设置为 (expected time to process single message) * 10
。
或者,SQS 会自动为我解决这个问题吗?如果是这样,我也很想了解这一点,因为我无法在文档中找到任何说明。
Does this mean I should set the VisibilityTimeout for the queue to be
(expected time to process single message) * 10.
是
Or, does SQS take care of this for me automagically?
没有。那怎么可能?一旦您收到 10 条消息,SQS 就无法了解您对它们进行的操作。它不知道应用程序中每条消息的 "processing" 是什么构成的。 SQS 只知道它向您的应用程序发送了 10 条消息。
或者,将 MaxNumberOfMessages
设置为 1
,以便您的应用程序一次仅从 SQS 接收一条消息。
ReceiveMessage
调用可以 return 来自队列 (http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html) 的最多 10 条消息。我正在使用长轮询。
我将遍历收到的消息列表并在单个线程中处理它们。这是否意味着我应该将队列的 VisibilityTimeout
设置为 (expected time to process single message) * 10
。
或者,SQS 会自动为我解决这个问题吗?如果是这样,我也很想了解这一点,因为我无法在文档中找到任何说明。
Does this mean I should set the VisibilityTimeout for the queue to be (expected time to process single message) * 10.
是
Or, does SQS take care of this for me automagically?
没有。那怎么可能?一旦您收到 10 条消息,SQS 就无法了解您对它们进行的操作。它不知道应用程序中每条消息的 "processing" 是什么构成的。 SQS 只知道它向您的应用程序发送了 10 条消息。
或者,将 MaxNumberOfMessages
设置为 1
,以便您的应用程序一次仅从 SQS 接收一条消息。