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 badges1 Answer
Reset to default 9Nevermind, I figured it out. It needs to be an array called AttributeNames. With an "s" at the end.
var params = {
QueueUrl : queueUrl,
AttributeNames : ['ApproximateNumberOfMessages']
}