简体   繁体   English

SNS 重新驱动到死信队列不起作用

[英]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.

相关问题 使用 CDK 授予对 SNS 主题订阅上的死信队列的权限 - Using CDK to grant permissions to Dead Letter Queue on SNS Topic Subscription 处理 AWS SQS 死信队列 - Handle AWS SQS Dead Letter Queue Amazon SQS - 如何验证队列是否为死信队列? - Amazon SQS - How to validate if a queue is a dead-letter queue? AWS 重新驱动到 Java 中的源队列 - AWS redrive to source queue in Java Lambda 的 AWS Cloudwatch 订阅过滤器和死信队列 - AWS Cloudwatch Subscription Filter and Dead Letter Queue for Lambda Azure函数中的Service Bus死信队列处理 - Service Bus Dead Letter Queue Processing In Azure Functions 代码没有错误,为什么消息仍然被发送到死信队列? - No bugs in codes, why messages are still being sent to Dead Letter Queue? 如何为使用 Terraform 生成的 SQS 队列获取死信队列的 URL? - How to get the URL for a Dead Letter Queue for an SQS queue generated using Terraform? 使用Boto3创建SQS队列时指定死信队列 - Specify a dead letter queue when creating an SQS queue using Boto3 即使主订阅者成功,pubsub 消息 go 也可以发送到死信队列吗? - Can pubsub messages go to the dead letter queue even if they succeed with the main subscriber?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM