SQS does not receive messages posted through SNS

I have a simple scenario of publish a message to a SNS topic, which is subscribed by a SQS queue, but somehow the queue never receives the messages (ie, not show up in the SQS console). Here are the codes in Ruby:

sns = Aws::SNS::Client.new;
sqs = Aws::SQS::Client.new;
q1 = sqs.create_queue({queue_name: "queue1”});
t1 = sns.create_topic({name: "topic1"});
q1_attr = sqs.get_queue_attributes({queue_url: q1.queue_url,attribute_names: ["All"]});
s1 = sns.subscribe({topic_arn: t1.topic_arn, protocol: "sqs", endpoint: q1_attr.attributes['QueueArn']});
resp = sns.publish({topic_arn: t1.topic_arn, message: "Test message"});

Is there anything missing?


The second quote in this line:

q1 = sqs.create_queue({queue_name: "queue1”});

is a 'fancy' quote instead of " . Change it to this:

q1 = sqs.create_queue({queue_name: "queue1"});
链接地址: http://www.djcxy.com/p/32200.html

上一篇: 未收到Amazon SES退回通知

下一篇: SQS不会收到通过SNS发布的消息