最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get Queue Attributes not working - Stack Overflow

programmeradmin0浏览0评论

I'm trying to get the approximate number of messages currently available in an SQS Queue. According to the documentation, I need to use getQueueAttributes, but I can't seem to get it to work. What am I doing wrong?

var params = {
  QueueUrl : queueUrl,
  AttributeName : 'ApproximateNumberOfMessages'
}

sqs.getQueueAttributes(params, function(err, data){
  console.log(data)
  //console.log(data.Attributes.ApproximateNumberOfMessages)
})

It keeps on returning null for data.

I'm trying to get the approximate number of messages currently available in an SQS Queue. According to the documentation, I need to use getQueueAttributes, but I can't seem to get it to work. What am I doing wrong?

var params = {
  QueueUrl : queueUrl,
  AttributeName : 'ApproximateNumberOfMessages'
}

sqs.getQueueAttributes(params, function(err, data){
  console.log(data)
  //console.log(data.Attributes.ApproximateNumberOfMessages)
})

It keeps on returning null for data.

Share Improve this question asked Oct 26, 2017 at 22:21 MattMatt 3051 gold badge5 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Nevermind, I figured it out. It needs to be an array called AttributeNames. With an "s" at the end.

var params = {
  QueueUrl : queueUrl,
  AttributeNames : ['ApproximateNumberOfMessages']
}
发布评论

评论列表(0)

  1. 暂无评论