如何处理忽略的SNS消息

发布于 2025-01-19 23:13:41 字数 492 浏览 0 评论 0 原文

我正在尝试使用AWS的SNS和SQS实现粉丝架构。就像本文https://betterprogramming.pub/how-to-fan-out-to-different-sqs-queues-using-sns-message-过滤-84CD23ED9D07

在上面的文章中,他有一个我想避免的全部队列。假设我有一个主题t和两个队列Q1和Q2订阅。 Q1接受“狗”,Q2接受“猫”。

我的问题是:

  1. 如果有人与马发布一条消息会发生什么?
  2. 如何处理任何队列都没有接收的消息? SNS DLQ最终会传达马消息吗?还是会丢弃它?

谢谢

I am trying to implement a fanout architecture using AWS' SNS and SQS. There will be a FIFO topic and several FIFO queues subscribed to it each having its own filtering policies just like in this article https://betterprogramming.pub/how-to-fan-out-to-different-sqs-queues-using-sns-message-filtering-84cd23ed9d07

In the article above he has a catch-all queue which I want to avoid. Lets assume I have a topic T and two queues Q1 and Q2 subscribed to it. Q1 accepts "dogs" and Q2 accepts "cats".

My questions are:

  1. If someone publishes a message with a horse what would happen?
  2. How can I handle a message that is not being picked up by any of the queues? Will SNS DLQ get the horse message eventually or will it be discarded?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枉心 2025-01-26 23:13:41

将消息发送到Amazon SNS主题时,然后将其发送给所有订户。如果队列上没有订户,则没有人会收到该消息。

来自

订阅在以下条件下接受消息:

  • 过滤器策略中的每个属性名称匹配分配给消息的属性名称。

  • 对于每个匹配属性名称,至少存在一项匹配:

    • 过滤策略中属性名称的值
    • 消息属性

因此,如果没有订阅接受消息,那么它与没有订阅者相同 - 没有人会收到消息。

请注意,消息不是“通过SQS队列接收”。相反,SNS主题将消息的副本转发给订户。无论是否发送一个订户,该消息都不会影响其他订户是否已发送消息。

来自

一个死信的队列是Amazon SQS队列,Amazon SNS订阅可以针对无法成功交付给订阅者的消息。由于客户端错误或服务器错误而无法传递的消息在死语队列中保存以进行进一步分析或重新处理。

因此,Amazon SNS Dead Letter队列仅用于具有交付失败的消息。它们不用于“没有订户想要的消息”。

When a message is sent to an Amazon SNS Topic, it is then sent to all subscribers. If there are no subscribers on the queue, then nobody will receive the message.

From Amazon SNS subscription filter policies - Amazon Simple Notification Service:

A subscription accepts a message under the following conditions:

  • Each attribute name in a filter policy matches an attribute name assigned to the message.

  • For each matching attribute name, at least one match exists between the following:

    • The values of the attribute name in the filter policy
    • The message attributes

Thus, if no subscription accepts the message, then it is the same as having no subscribers -- nobody will receive the message.

Please note that messages are not "picked up by the SQS queues". Rather, the SNS Topic forwards a copy of the message to the subscribers. Whether or not one subscriber is sent the message has no impact on whether other subscribers are sent the message.

From Amazon SNS dead-letter queues (DLQs) - Amazon Simple Notification Service:

A dead-letter queue is an Amazon SQS queue that an Amazon SNS subscription can target for messages that can't be delivered to subscribers successfully. Messages that can't be delivered due to client errors or server errors are held in the dead-letter queue for further analysis or reprocessing.

Thus, Amazon SNS Dead Letter Queues are only used for messages that have a delivery failure. They are not used for 'messages that no subscriber wanted'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文