0
votes

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 (i.e., 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?

1
You haven't confirmed the subscriptionFrederick Cheung
Fred: which subscription? I don't see anyDuc Tran
After subscribing the queue to the topic (penultimate line) you need to confirm the subscriptionFrederick Cheung

1 Answers

1
votes

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"});