您可以查询主题或订阅,但无法查询已发布的邮件。我怀疑AWS是否保留了它们,但如果保留了,就我所知,没有API可以访问它们。
一种解决方法是在自己的站点上使用http或https端点订阅每个主题。每次创建主题时,都会创建一个对应于自己端点的订阅:
def generate_sns_topic(topic_name)
sns_client = Aws::SNS::Client.new
response = sns_client.create_topic(name: topic_name)
if response.successful?
sns_client.subscribe(topic_arn: topic_response.topic_arn,
protocol: :https,
endpoint: <your_site_endpoint>)
else
<error_handling_here>
end
end
现在您需要创建
POST <your_site_endpoint>
接收AWS消息。一旦你收到它,你就会知道SNS已经发送了它。大概你会创建一个新的
published_messages