AWS SQS Boto3 手动将消息发送到死信 [英] AWS SQS Boto3 sending messages to dead letter manually

查看:43
本文介绍了AWS SQS Boto3 手动将消息发送到死信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在构建一个使用 SQS 的小型应用程序.我有一个简单的处理程序进程,用于确定给定的消息是否被视为已处理、标记为重试(重新排队)或无法处理(应发送至死信).

So I am building a small application that uses SQS. I have a simple handler process that determines if a given message is considered processed, marked for retry (to be re-queued) or is not able to be processed (should be sent to dead letter).

然而,根据文档,真正向 DL 发送消息的唯一方法是使用重新驱动策略,该策略在接收到的消息数量上运行.由于我的应用程序的性质,如果我的进程没有准备好处理给定的消息,我可以进行多次有效的重试,但有时我可能想要对刚刚收到的消息进行 DL.AWS/Boto3 是否没有提供一种为 DL 标记特定消息的方法?

However based on the docs it would appear the only way to truly send a message to DL is by using a redrive policy which operates over # of receives a message has racked up. Because of the nature of my application, I could have several valid retries if my process isn't ready to handle a given message, but there are also times I may want to DL a message I have just received. Does AWS/Boto3 not provide a way to mark a specific message for DL?

我知道我可以自己将消息发送到我认为是我自己的 DL 的另一个队列,我宁愿为此使用 AWS 的内置工具.

I know I can just send the message myself to another queue I consider my own DL, I would just rather use AWS' built in tools for this.

推荐答案

我认为没有任何限制会阻止您自己将消息发送到交易信函队列.

I don't believe there is any limitation that would prevent you from sending the message to the deal-letter-queue by yourself.

所以只要从Q中读取消息,如果你知道它需要直接去DLQ,将它发送到DLQ并从常规Q中移除.

So just read the message from the Q, if you know it needs to go to the DLQ directly, send it to the DLQ and remove it from the regular Q.

这篇关于AWS SQS Boto3 手动将消息发送到死信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆