AWS SQS returns 2 到 4 条消息,即使在 MaxNumberOfMessages 参数设置为 10 并且队列有 13 条消息之后
AWS SQS returns 2 to 4 messages even after MaxNumberOfMessages parameter is set to 10 and queue has 13 messages
我有一个标准 AWS SQS,其中包含 13 条消息。我写了一个简单的 JavaScript 函数来使用长轮询获取 10 条消息。
代码如下:
/* aws config */
Poller.prototype.poll = async function() {
let response;
try{
response = await this.SQS.receiveMessage({
QueueUrl: "https://sqs.region.amazonaws.com/user_id/queue_name",
MaxNumberOfMessages: 10,
VisibilityTimeout: 20,
WaitTimeSeconds: 20
}).promise();
return response;
} catch(err) {
console.log('its an error');
/* handel error */
}
}
每次我 运行 这个代码它 returns 2 条消息然后 4 条这样继续。我试过弄乱 WaitTimeSeconds
和 VisibilityTimeout
但没用。
我是 AWS SQS 的新手,在此先感谢。 :)
这不是异常行为 - 根据我的经验,您实际上指定最多 'upto' 10 条消息,除非队列有很多记录(hundreds/thousands 或更多),而不是返回的小数字意料之中。
我有一个标准 AWS SQS,其中包含 13 条消息。我写了一个简单的 JavaScript 函数来使用长轮询获取 10 条消息。
代码如下:
/* aws config */
Poller.prototype.poll = async function() {
let response;
try{
response = await this.SQS.receiveMessage({
QueueUrl: "https://sqs.region.amazonaws.com/user_id/queue_name",
MaxNumberOfMessages: 10,
VisibilityTimeout: 20,
WaitTimeSeconds: 20
}).promise();
return response;
} catch(err) {
console.log('its an error');
/* handel error */
}
}
每次我 运行 这个代码它 returns 2 条消息然后 4 条这样继续。我试过弄乱 WaitTimeSeconds
和 VisibilityTimeout
但没用。
我是 AWS SQS 的新手,在此先感谢。 :)
这不是异常行为 - 根据我的经验,您实际上指定最多 'upto' 10 条消息,除非队列有很多记录(hundreds/thousands 或更多),而不是返回的小数字意料之中。