首页 > 解决方案 > How to save failed messages from Amazon SNS into Amazon S3

问题描述

I would like to know if it's possible to persist all unacknowledged messages from an SNS topic to an S3 file given a certain time window. These messages don't necessarily need to follow the original order in the S3 file, a timestamp attribute is enough.

标签: amazon-web-servicesamazon-sns

解决方案


没有将消息从 Amazon SNS 保存到 Amazon S3 的内置功能。

然而,本周 AWS 为 Amazon SNS 引入了死信队列。

Amazon SNS 添加对死信队列 (DLQ) 的支持

您现在可以为 Amazon Simple Notification Service (SNS) 订阅设置死信队列 (DLQ),以捕获无法送达的消息。Amazon SNS DLQ 通过存储消息以防您的订阅终端节点无法访问,从而使您的应用程序更具弹性和持久性。

Amazon SNS DLQ 是标准的 Amazon SQS 队列。

因此,如果 Amazon SNS 无法传递消息,它可以自动将其发送到 Amazon SQS 队列。您可以稍后查看/处理这些失败的消息。例如,您可以创建一个AWS Lambda 函数,当消息到达死信队列时触发该函数。然后该函数可以将消息存储在 Amazon S3 中。


推荐阅读