简体   繁体   English

SQS真的会为每条消息发送多个S3 PUT对象记录吗?

[英]Does SQS really send multiple S3 PUT object records per message?

I've set up an S3 bucket to emit an event on PUT object to SQS, and I'm handling the SQS queue in an EB worker tier. 我已经设置了一个S3存储桶来将PUT对象上的事件发送到SQS,我正在处理EB工作层中的SQS队列。

The schema for the message that SQS sends is here: http://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html SQS发送的消息的架构如下: http//docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html

Records is an array, implying that there can be multiple records sent in one POST to my worker's endpoint. 记录是一个数组,意味着可以在一个POST中将多个记录发送到我的工作人员的端点。 Does this actually happen? 这实际发生了吗? Or will my worker only ever receive one record per message? 或者我的工作人员每封邮件只会收到一条记录吗?

The worker can only return one response, either 200 (message handled successfully) or non-200 (message not handled successfully, which puts it back into the queue), regardless of how many records in the message it receives. 无论收到的消息中有多少记录,工作者只能返回一个响应,200(成功处理消息)或非200(消息未成功处理,将其重新放入队列)。

So if my worker receives multiple records in a message, and it handles some successfully (say by doing something with side effects such as inserting into a database) but fails on one or more, how should I handle that? 因此,如果我的工作人员在一条消息中收到多条记录,并且它成功地处理了一些(例如通过插入数据库等副作用)但是在一个或多个上失败,我应该如何处理? If I return 200, then the ones that failed will not be retried. 如果我返回200,那么失败的那些将不会被重试。 But if I return non-200, then the ones that were handled successfully will be retried unnecessarily, and possibly re-inserted. 但是如果我返回非200,那么成功处理的那些将被不必要地重试,并且可能重新插入。 So I'd have to make my worker smart enough to retry only the failed ones -- which is logic I'd prefer not having to write. 因此,我必须让我的工作人员足够聪明,只能重试失败的 - 这是我不想写的逻辑。

This would be much easier if only one record was ever sent per message. 如果每封邮件只发送一条记录,这将更容易。 So if that's the case in practice, despite records being an array, I'd really like to know! 所以,如果实际情况如此,尽管记录是阵列,我真的很想知道!

To be clear, it's not the records that "SQS sends." 要清楚,这不是“SQS发送”的记录。 It's the records that S3 sends to SQS (or to SNS, or to Lambda). 这是S3发送给 SQS(或SNS或Lambda)的记录。

Currently, all S3 event notifications have a single event per notification message. 目前,所有S3事件通知每个通知消息都有一个事件。 We might include multiple records as we add new event types in the future. 我们可能会在将来添加新事件类型时包含多个记录。 This is also a message format that is shared across other AWS services, and other services can include multiple records. 这也是跨其他AWS服务共享的消息格式,其他服务可以包含多个记录。

https://forums.aws.amazon.com/thread.jspa?messageID=592264&#592264 - https://forums.aws.amazon.com/thread.jspa?messageID=592264&#592264

So, for the moment, it appears there's only one record per message. 所以,目前看来每封邮件只有一条记录。

But... you are making a mistake if you assume your application need not be prepared to handle repeated or duplicate messages. 但是......如果您认为您的应用程序不需要准备处理重复或重复的消息,那么您就犯了一个错误。 In any massive and distributed system like SQS it is extremely difficult to absolutely guarantee that this can never happen, however unlikely: 在任何像SQS这样的大规模分布式系统中,绝对保证绝对不会发生这种情况是极其困难的,但不太可能:

Q: How many times will I receive each message? 问:我会收到多少次邮件?

Amazon SQS is engineered to provide “at least once” delivery of all messages in its queues. Amazon SQS旨在为其队列中的所有消息提供“至少一次”传递。 Although most of the time each message will be delivered to your application exactly once, you should design your system so that processing a message more than once does not create any errors or inconsistencies. 虽然大多数情况下每条消息只会传递给您的应用程序一次,但您应该设计系统,以便多次处理消息不会产生任何错误或不一致。

http://aws.amazon.com/sqs/faqs/ - http://aws.amazon.com/sqs/faqs/

Incidentally, in my platform, more than one entry in the records array is considered an error, causing the message to be abandoned and sent to the dead letter queue for review. 顺便说一句,在我的平台中,记录数组中的多个条目被视为错误,导致该消息被放弃并发送到死信队列以供查看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 写后读一致性对 S3 中的新对象 PUT 的真正含义是什么? - What does read-after-write consistency really mean on new object PUT in S3? s3-文件上传-多个sqs队列中的消息 - s3 - file uploaded - message in multiple sqs queues 关于 SQS 和 S3 的问题是否可以连接 SQS 以直接发布到 S3 消息 - Question on SQS and S3 is it possible to wire SQS to publish straight to a S3 message 将AWS S3事件转发到SQS最终会变成与从S3到SNS到SQS不同的消息吗? - Will AWS S3 event forwarding to SQS will end up being a different message than S3 to SNS to SQS? 将消息从 S3 中托管的网页发送到 SQS 队列 - Sending message from webpage hosted in S3 to SQS queue 通过 S3 和 SQS 事件触发消息传递变量值 - Passing variable values through S3 and SQS event trigger message Lambda函数处理了多个SQS记录后发送电子邮件 - Send an email after multiple SQS records are processed by a Lambda function 可以将SQS消息属性添加到S3事件生成的SQS消息中吗? - Can you add SQS message attributes to SQS messages generated by S3 events? “指定的密钥不存在”存储桶中真正存在的对象的S3错误 - “The specified key does not exist” S3 error for really existing object in the bucket S3 向 SQS 发送消息,EC2 脚本检查消息是否存在 - S3 Sends Message to SQS and EC2 Script Checks If Message Exists
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM