单个平方英尺来处理多种类型的消息或为每种消息类型具有一个SQS队列
我正在使用一个AWS SQS发送电子邮件。 听众接收电子邮件的JSON并直接对其进行处理。 现在,我还需要发送另一种消息类型(假设OTP或警报),这些消息将具有其自己的JSON结构。
我可以使用相同的SQS队列发布这些不同类型的消息,因为我的音量非常低,或者我应该继续为每种消息类型创建多个SQS队列。
I am using one AWS SQS for sending the emails.
The listener receives the json of the email and directly processes it.
Now, I also need to send one more message type (lets say otp or alert) and these will have its own json structure.
Can I use the same SQS Queue for posting these different type of messages as my volume is very low or should I go ahead and create multiple SQS Queue for each message type.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用SQS,1个队列就足够了,但是您需要一个lambda来过滤和将事件路由到相应的操作(例如
如果事件A - >发送电子邮件代码>)。您可以按建议使用多个SQS队列,因此您不需要路由lambda。但是,无论哪种方式,它都涉及创建大量资源。
取而代之的是,一个更好的选择是AWS EventBridge(以前称为CloudWatch事件)。请参阅本文示例 。基本上,EventBridge允许您创建规则以过滤已发布的事件并路由匹配事件以触发目标。因此,您只需要使用EventBridge,而不必维护SQS队列(或您建议的多个路由Lambda),这要容易得多。
您只需要编码发送电子邮件lambda,发送OTP lambda,然后发送警报lambda即可。
Using SQS, 1 queue is sufficient, but then you need a Lambda for filtering and routing the events to the corresponding action (such as
if event A -> send email, else if event B -> send OTP
). You can use multiple SQS queues, as you suggested, then you don't need the routing Lambda. But either way it involves creating a lot of resources.Instead, a better option is AWS EventBridge (previously known as CloudWatch Events). See this article for examples. Basically, EventBridge lets you create rules to filter published events and route the matching events to trigger a target. Hence, instead of having to maintain an SQS queue (or multiple as you suggest) and a routing Lambda, you just need to use EventBridge, which is much easier to maintain.
You only need to code the Send Email Lambda, Send OTP Lambda, and Send Alert Lambda.
是非常主观的:
这 您的接收器是否能够处理两种类型的消息。
b。将来,您是否需要将接收器分别扩展到不同类型的消息。
c。大多数IMP都是在队列中的所有消息,都具有同等的重要性/优先级,假设您在队列中有大量与电子邮件相关的JSON,然后出现基于OTP/警报的消息。相关消息。如果没有,那么对于此类消息,有一个单独的高优先级队列是有意义的。
This is very subjective:
a. Is your receiver able to handle both types of messages.
b. Would you need to scale the receivers separately for different types of messages in the future.
c. And most imp are all messages on the queue of equal importance/priority, assume you have a ton of emails related jsons in the queue and then a OTP/Alert based message comes in. Is it ok for that message to be processed after the email related messages. If not it makes sense to have a separate high priority queue for these kind of messages.
如果要使用一个队列,则需要一个lambda功能,该功能将对这些消息进行实际过滤。然后基于过滤器结果,Lambda功能将采取进一步的操作,例如使用SNS发送一些通知。
If you want to use one queue, you need a lambda function which is going to do the actual filtering of these messages. And then based on the filter outcomes, the lambda function would take further actions, e.g. send some notifications using SNS.