Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use boto to get aws sqs message already in flight [closed]

I tried boto api and seems that no api can get message number already in flight? Does anyone give me a hint how to get this number?

like image 403
guile chao Avatar asked Feb 12 '23 07:02

guile chao


1 Answers

To find the messages in flight or any of the other attributes of an SQS queue in boto, you need to do this:

import boto.sqs
c = boto.sqs.connect_to_region('us-east-1')
queue = c.lookup('myqueue')
attr = queue.get_attributes()

This will a python dictionary that looks like this:

{u'ApproximateNumberOfMessages': u'0',
 u'ApproximateNumberOfMessagesDelayed': u'0',
 u'ApproximateNumberOfMessagesNotVisible': u'0',
 u'CreatedTimestamp': u'1412270007',
 u'DelaySeconds': u'0',
 u'LastModifiedTimestamp': u'1412270007',
 u'MaximumMessageSize': u'262144',
 u'MessageRetentionPeriod': u'345600',
 u'QueueArn': u'arn:aws:sqs:us-east-1:723405645490:16ac1da3-564c-43aa-8dcb-4db41ece50ea',
 u'ReceiveMessageWaitTimeSeconds': u'0',
 u'VisibilityTimeout': u'30'}

I believe the ApproximateNumberOfMessagesNotVisible is equivalent to the in-flight statistic reported by the console.

like image 144
garnaat Avatar answered Apr 28 '23 14:04

garnaat