Tuesday, July 15, 2014

Receiving SQS messages through SNS - Decoding the payload

From Mitch Garnaat's post on the subject:

http://www.elastician.com/2010/04/subscribing-sqs-queue-to-sns-topic.html

User Chris Moyer points out:

One very important thing to note here is that the messages from SNS do NOT come through as base64 encoded, so you'll have to set the message class to "RawMessage" first:

from boto.sqs.message import RawMessage
q.set_message_class(RawMessage)
msg = q.read()

Also, the message "payload" is actually stored under "Message" in the provided JSON:

msg_data = json.loads(msg.get_body())['Message']

1 comment:

  1. It was very nice article and it is very useful to Linux learners.We also provide Linux online training

    ReplyDelete