tag:blogger.com,1999:blog-1231480044619721857.post2485889771648457896..comments2022-12-02T05:07:00.365-05:00Comments on Elastician: Subscribing an SQS queue to an SNS topicMitch Garnaathttp://www.blogger.com/profile/02589240083555476561noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-1231480044619721857.post-69651335138485280802012-03-21T12:39:29.433-04:002012-03-21T12:39:29.433-04:00and the policy should be more like:
{"Version...and the policy should be more like:<br />{"Version": "2008-10-17", "Statement": [{"Resource": "arn:aws:sqs:us-east-1:963068290131:TestSNSNotification", "Effect": "Allow", "Sid": "ad279892-1597-46f8-922c-eb2b545a14a8", "Action": "SQS:SendMessage", "Condition": {"SourceArn": {"aws:SourceArn": "arn:aws:sns:us-east-1:963068290131:TestSQSTopic"}}, "Principal": {"AWS": "*"}}]}<br />(notice the SourceArn instead of StringLike.<br /><br />I may be late for the party, sorry Kurt...Brice Laurencinhttps://www.blogger.com/profile/04041602758348936158noreply@blogger.comtag:blogger.com,1999:blog-1231480044619721857.post-82262656318580862842011-08-23T12:43:10.937-04:002011-08-23T12:43:10.937-04:00One very important thing to note here is that the ...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:<br /><br />from boto.sqs.message import RawMessage<br />q.set_message_class(RawMessage)<br />msg = q.read()<br /><br />Also, the message "payload" is actually stored under "Message" in the provided JSON:<br /><br />msg_data = json.loads(msg.get_body())['Message']Anonymoushttps://www.blogger.com/profile/04068315333804202241noreply@blogger.comtag:blogger.com,1999:blog-1231480044619721857.post-42282484355162435772010-11-03T06:14:08.854-04:002010-11-03T06:14:08.854-04:00Hey
I cant seem to subscribe a queue to a sns top...Hey<br /><br />I cant seem to subscribe a queue to a sns topic. Would appreciate some help. I have been trying for 2 days now.<br /><br />here is the code im using:<br /><br />q = conn.get_queue('Synctestq')<br />snsconn.subscribe_sqs_queue('arn:aws:sns:us-east-1:797755126197:Topictest1', q)<br /><br />policy = {'Id':'SQSDefaultPolicy','Version': '2008-10-17','Statement':[{'Action':'SQS:SendMessage','Condition':{'StringLike':{'AWS:SourceArn':'arn:aws:sns:us-east-1:797755126197:SNStest'}},'Effect':'Allow','Principal':{'AWS':'*'},'Resource': 'arn:aws:sqs:us-east-1:797755126197:Synctestq','Sid': '1'}]}<br /><br />q.set_attribute('Policy', policy)Kurt Campherhttps://www.blogger.com/profile/02814375988550825396noreply@blogger.comtag:blogger.com,1999:blog-1231480044619721857.post-6588357520063334862010-04-20T16:20:42.140-04:002010-04-20T16:20:42.140-04:00Traceback (most recent call last):
File "&q...Traceback (most recent call last):<br /> File "", line 1, in <br /> File "/Users/director/dev/virtual/sns/src/svn/boto/sns/__init__.py", line 280, in subscribe_sqs_queue<br /> resp = self.subscribe(topic, 'sqs', q_arn)<br /> File "/Users/director/dev/virtual/sns/src/svn/boto/sns/__init__.py", line 253, in subscribe<br /> raise self.ResponseError(response.status, response.reason, body)<br />boto.exception.BotoServerError: BotoServerError: 403 Forbidden<br />{"Error":{"Code":"AuthorizationError","Message":"Access denied by policy","Type":"Sender"},"RequestId":"f4243ba7-4cb9-11df-8254-35bf49fc28f1"}Batokhttps://www.blogger.com/profile/01896692220559183675noreply@blogger.comtag:blogger.com,1999:blog-1231480044619721857.post-54282856969537329212010-04-20T14:53:51.044-04:002010-04-20T14:53:51.044-04:00I've not had any problems today. What error a...I've not had any problems today. What error are you receiving?Mitch Garnaathttps://www.blogger.com/profile/02589240083555476561noreply@blogger.comtag:blogger.com,1999:blog-1231480044619721857.post-34212325998077616692010-04-20T13:02:34.464-04:002010-04-20T13:02:34.464-04:00Mitch,
I tried to subscribe a queue today withou...Mitch, <br /><br />I tried to subscribe a queue today without sucess. Don't know if Amazon changed something. Are you expiencing the same problems?Batokhttps://www.blogger.com/profile/01896692220559183675noreply@blogger.comtag:blogger.com,1999:blog-1231480044619721857.post-31424673698591657212010-04-19T23:25:43.113-04:002010-04-19T23:25:43.113-04:00After the subscription of the queue is done, the m...After the subscription of the queue is done, the message arrives to queue as a json string. The key "Message" from json / dict has the value that was published.<br /><br />I've done this...<br />import json<br /><br />m = queue.read()<br />print json.loads(m.get_body()).get("Message")Batokhttps://www.blogger.com/profile/01896692220559183675noreply@blogger.com