简体   繁体   English

AWS SQS 发送了 4 条消息,但 lambda 被调用了两次

[英]AWS SQS sent 4 messages but lambda invoked twice

My SQS FIFO triggers lambda function. SQS sent 4 messages but lambda invoked twice.我的 SQS FIFO 触发 lambda function。SQS 发送了 4 条消息,但 lambda 被调用了两次。 Concurrency is "Unreserved account concurrency & 1000".并发数是“未预留账户并发数 & 1000”。 What can go wrong? go有什么错?

The AWS Lambda function can be invoked with more than one Record in the event . AWS Lambda function 可以在event中用多个 Record 调用。

For example, in Python you would process the event like this:例如,在 Python 中,您将像这样处理事件:

def lambda_handler(event, context):
    for record in event['Records']:
      message = record['Sns']['Message']
      print("From SNS: " + message)

The maximum number of messages passed to a Lambda function can be controlled with the Batch Size parameter in the trigger:传递给 Lambda function 的最大消息数可以通过触发器中的Batch Size参数来控制:

来自 SQS 的 AWS Lambda 触发器

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM