管理AWS SQS和DLQ [英] managing AWS SQS and DLQ

查看:147
本文介绍了管理AWS SQS和DLQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:

创建一个lambda,只要有消息到达SQS(假设SQS-A),就会触发该lambda. lambda(用python编写)负责将传入的有效负载发送到另一个端点.

create a lambda and it will be triggered whenever a message comes to SQS(let's assume SQS-A). The lambda (written in python)is responsible for sending the incoming payload to the another endpoint.

问题是,只要目标端点或服务器停机,我就会尝试将其放入另一个SQS(假设SQS-B),而不是将其放入交易信函队列"中.

The problem is, whenever the target endpoint or server is down, I was trying to place it into the another SQS (let's assume SQS-B), if other exceptions comes than placing it into Deal Letter Queue.

在这里我想做两件事.

Here I want to two things.

  1. 如果ConnectionError(这是python异常说端点已关闭)来了,我想停止SQS-A(当目标服务器关闭时,没有必要运行lambda).

(或)

  1. 每当我收到此错误时,就将其发送到SQS-B,我希望在第一个请求到来时触发SQS-B,并且它应该检查是否仍然存在连接错误,因此必须触发10分钟后,再检查一次,如果30分钟后异常仍然存在,则触发,像这样 我想将时间最多增加4小时,然后每4小时检查/触发一次lambda.如果没有异常,则它应读取SQS-B中的所有消息.
  1. As whenever I get this error I am sending it to the SQS-B, I want the SQS-B to be triggered for when the first request comes and it should check if still there is a connection error, it has to trigger after 10 minutes, and again check, if exception persists trigger after 30 minutes, like this I want to increment the time up to 4 hours and after that check/trigger the lambda every 4 hours. If there is no exception then it should read all the messages in the SQS-B.

帮助我如何实现上述任何一种方法或推荐其他更好的方法

Help me how to achieve any one of the approach or recommend any other better approach

推荐答案

由于一个简单的问题(目标不可用),您正在创建复杂的体系结构.尽量不要使事情过于复杂.

You are creating a complex architecture due to a simple problem (the target not being available). Try not to over-complicate things.

我建议:

  • 让原始系统将消息发送到 Amazon SNS主题
  • 主题触发Lambda函数
    • 如果成功处理了消息,则无需采取进一步措施
    • 如果远程端点不可用,请将消息放入 Amazon SQS队列以供以后处理
    • Have the originating system send the message to an Amazon SNS topic
    • The topic triggers a Lambda function
      • If it successfully processes the message, no further action required
      • If the remote endpoint is not available, put the message into an Amazon SQS queue for later processing
      • 如果消息的时间超过几个小时,可能还值得向管理员发送电子邮件.

      如果您必须将原始消息发送到SQS队列,则可以按照您描述的方式进行操作...首先发送到Queue-A,这将触发Lambda函数.如果端点已关闭,Lambda会将消息发送到Queue-B进行后续处理.但是,仅每 n 分钟就从Queue-B处理一次(而不是试图使每个单独的消息都有自己的延迟计时器).

      If you must send the original message to an SQS queue, then you could do as you described... send to Queue-A first, which triggers a Lambda function. If the endpoint is down, Lambda sends the message to Queue-B for later processing. However, only process from Queue-B every n minutes (rather than trying to make each individual message have its own delay timer).

      这篇关于管理AWS SQS和DLQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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