【问题标题】:AWS SQS returns 2 to 4 messages even after MaxNumberOfMessages parameter is set to 10 and queue has 13 messages即使 MaxNumberOfMessages 参数设置为 10 并且队列有 13 条消息,AWS SQS 也会返回 2 到 4 条消息
【发布时间】:2019-06-14 20:46:32
【问题描述】:

我有一个标准的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 */
    }
  }

每次我运行此代码时,它都会返回 2 条消息,然后返回 4 条消息,并继续。我试过弄乱WaitTimeSecondsVisibilityTimeout 但没用。

我是 AWS SQS 的新手,提前致谢。 :)

【问题讨论】:

    标签: amazon-web-services amazon-sqs aws-sdk-js


    【解决方案1】:

    这不是不寻常的行为 - 根据我的经验,您实际上最多指定“最多”10 条消息,除非队列有很多记录(数十/千或更多),而不是预期返回的少量记录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-14
      • 1970-01-01
      • 2014-08-17
      • 2020-03-20
      相关资源
      最近更新 更多