Reputation: 63
I have the following code snippet.
conn = boto.sqs.connect_to_region(region)
q = conn.lookup('myqueue')
m = Message()
m.set_body('My Message')
data = {"UserID": {"data_type": "Number","string_value": "11111"}}
m.message_attributes = user_data
q.write(m)
Using this, I have successfully written the attributes I wanted with the message. Now, I wanted to retrieve it. I have tried
msg.message_attributes
But I have got an empty dictionary only.
Is this the way to retrieve it? Or am I wrong somewhere?
Upvotes: 0
Views: 2162
Reputation: 63
I have got the answer to my question.
For this you must have retrieved the message like this
attributes = ['UserID']
msgs = q.get_messages(message_attributes=attributes)
Will get msgs as a list. And let msg be msgs[0] Then the message attribute can be retrieved by the following code.
msg.message_attributes['UserID']['string_value']
Upvotes: 2