SQS使用多个记录/消息触发Lambda吗? [英] SQS triggers Lambda with multiple records/messages?

查看:241
本文介绍了SQS使用多个记录/消息触发Lambda吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我观察到一个异常(在我的POV中)功能,当我设置SQS来触发Lambda时,当新消息到达时,Lambda会在其事件主体中被超过1条记录/消息触发. >

完整设置为S3(PutObjectEvent)-> SNS主题-> SQS-> Lambda.

异常行为是,例如,我在S3中放入了15个对象,然后将每个对象转发一个事件到SNS,然后我可以观察到,SQS填充了15条消息.但是,当Lambda开始触发时,在这15条消息中,只有11条Lambda触发,其中一些Lambda在其事件主体中包含多于1条记录/消息.

我已经搜索了AWS文档,但是没有找到具体的答案.请注意,这些Lambda不会轮询SQS或失败或继续重试.他们执行得很好,只是检查的事件正文显示了其中的1条以上记录.

解决方案

查看SQS Lambda消息的示例事件数据有关SQS Lambda集成的文档也很明显指出Batch Size设置控制一次调用中Lambda函数可以从SQS接收多少记录,默认值为10.如果只希望Lambda函数一次接收一条消息,则需要将Batch Size设置修改为1.

I've observed an abnormal (well, in my POV) feature, where when I setup SQS to trigger a Lambda, when new messages arrive, lambdas get triggered with more than 1 record/message inside its event body.

Full setup is S3 (PutObjectEvent) -> SNS topic -> SQS -> Lambda.

The abnormal behaviour is that for example, let's say I put 15 objects inside S3, which then forwards an event to SNS per each object, which then I can observe, SQS gets populated with 15 messages. However, when Lambdas start triggering, out of those 15 messages, only 11 Lambdas trigger, some of them containing more than 1 record/message inside its event body.

I've scoured the AWS documentation, but haven't found a concrete answer. Please note, these Lambdas do NOT poll SQS or fail or keep retrying. They execute perfectly fine, its just that inspected event body shows more than 1 record inside of it.

解决方案

Look at the sample event data for an SQS Lambda message here. The message is an array of records, which directly implies that there may be more than one SQS record in the message.

The documentation on SQS Lambda integration also clearly states that the Batch Size setting controls how many records a Lambda function may receive from SQS in a single call, with the default being 10. If you only want your Lambda functions to receive one message at a time you need to modify the Batch Size setting to be 1.

这篇关于SQS使用多个记录/消息触发Lambda吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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