[英]SNS redrive to Dead letter queue not working
I have a queue with a policy:我有一个带有策略的队列:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com"
},
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:us-west-2:*:example-dlq",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:sns:us-west-2:*:example-sns"
}
}
}
]
}
I also have an SNS created and a subscription, that has a redrive policy:我还创建了一个 SNS 和一个具有重新驱动策略的订阅:
{
"deadLetterTargetArn": "arn:aws:sqs:us-west-2:*:example-dlq"
}
The subscription endpoint is a lambda, so the lambda fails 3 times (I can see that in the log), but the message never reaches the DLQ.订阅端点是 lambda,因此 lambda 失败了 3 次(我可以在日志中看到),但消息从未到达 DLQ。
What could be wrong?有什么问题吗? I've read the documentation and it does not need any extra step to work ( https://docs.aws.amazon.com/sns/latest/dg/sns-configure-dead-letter-queue.html ).
我已经阅读了文档,它不需要任何额外的步骤即可工作( https://docs.aws.amazon.com/sns/latest/dg/sns-configure-dead-letter-queue.html )。 My only difference is that in the example the endpoint is another queue instead of a Lambda.
我唯一的区别是在示例中端点是另一个队列而不是 Lambda。
Thanks in advance提前致谢
Okay I will answer my own question.好的,我会回答我自己的问题。
SNS delivers the message into the lambda but it does not care if it's failing or not (throwing an error), so the Dead Letter Queue for SNS only works when Lambda service is unavailable. SNS 将消息传递到 lambda 但它并不关心它是否失败(抛出错误),因此 SNS 的死信队列仅在 Lambda 服务不可用时起作用。
As this is an async event, you can set in the lambda a retry config and dead letter queue.由于这是一个异步事件,您可以在 lambda 中设置重试配置和死信队列。
Or you can use SQS instead of SNS.或者您可以使用 SQS 而不是 SNS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.