Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQS: How can I read the sent time of an SQS message using Python's boto library

I can see messages have a sent time when I view them in the SQS message view in the AWS console. How can I read this data using Python's boto library?

like image 211
Ollie Glass Avatar asked Feb 18 '13 21:02

Ollie Glass


2 Answers

When you read a message from a queue in boto, you get a Message object. This object has at attribute called attributes. It is a dictionary of attributes that SQS keeps about this message. It includes SentTimestamp.

like image 136
garnaat Avatar answered Sep 29 '22 06:09

garnaat


You can use the attributes parameter of the get_message() method. See the documentation.

queue.get_messages(attributes=['All'])

The documentation also says that you can do this with the read() method but this is broken right now. I opened an issue for this on the project site: https://github.com/boto/boto/issues/2699.

like image 33
stuckintheshuck Avatar answered Sep 29 '22 05:09

stuckintheshuck