我目前正在使用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'
}
}如上面的代码块所示,ApproximateNumberOfMessagesNotVisible和ApproximateNumberOfMessagesDelayed是否包含在ApproximateNumberOfMessages值中?
发布于 2022-01-11 21:52:41
不不包括在内。ApproximateNumberOfMessages是当前可用于重审的消息数量:
可用于从队列中检索的消息数。
对于标准队列,这些值仅是近似的,可能不代表实际出现的消息数:
对于标准队列,由于Amazon的分布式体系结构,结果是近似。
https://stackoverflow.com/questions/70673469
复制相似问题