SQS ApproximateNumberOfMessages 属性是否包括延迟和不可见的消息?

Does the SQS ApproximateNumberOfMessages attribute include the delayed and not visible messages?

我目前正在使用 AWS 的 SQS。每隔 60 秒,我的应用程序就会从队列中提取所有消息并进行处理。鉴于我只能在单个请求中检索最多 10 条消息,我想查询 ApproximateNumberOfMessages 的队列。队列中的近似消息数决定了我需要调用 SQS 多少次才能检索队列中的所有消息。

当我向 SQS 查询队列属性时,我得到:

{
  '$metadata': {
    httpStatusCode: 200,
    requestId: '...',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Attributes: {
    QueueArn: 'arn:...',
    ApproximateNumberOfMessages: '0',           <--- helpful
    ApproximateNumberOfMessagesNotVisible: '0', <--- is this attribute included in the `ApproximateNumberOfMessages`
    ApproximateNumberOfMessagesDelayed: '0',    <--- is this attribute included in the `ApproximateNumberOfMessages`
    CreatedTimestamp: '1641925448',
    LastModifiedTimestamp: '1641925448',
    VisibilityTimeout: '30',
    MaximumMessageSize: '262144',
    MessageRetentionPeriod: '345600',
    DelaySeconds: '90',
    RedrivePolicy: '{"deadLetterTargetArn":"arn:...","maxReceiveCount":4}',
    ReceiveMessageWaitTimeSeconds: '0',
    SqsManagedSseEnabled: 'false'
  }
}

如上面的代码块所示,ApproximateNumberOfMessagesNotVisibleApproximateNumberOfMessagesDelayed 是否包含在 ApproximateNumberOfMessages 值中?

不,它们不包括在内。 ApproximateNumberOfMessages为当前可重试的消息数:

The number of messages available for retrieval from the queue.

同样对于标准队列,这些值只是近似值,可能不代表存在的实际消息数:

For standard queues, the result is approximate because of the distributed architecture of Amazon SQS.