简体   繁体   中英

SQS messages to trigger same lambda function instances one to one

I have a requirement where at a single point of time each SQS messages in the same SQS queue should trigger separate lambda instances

For Example the SQS queue has n number of messages at a given time then expectation is, it should trigger n instance of lambdas

Message_1 --> Lambda_function_A_instance_1
Message_2 --> Lambda_function_A_instance_2
Message_n --> Lambda_function_A_instance_n

Use case: Need to keep separate instance of lambda functions for each messages in order to process data files which are > 10G.. So each message will invoke new lamnda instance of the same function

To configure Lambda to read only one message from SQS at a time, you need to set the BatchSize parameter to 1 when creating the SQS event source mapping. This will ensure that only one message is read from the queue at a time.

Additionally, you can set the VisibilityTimeout parameter to a value that is greater than the Lambda function's timeout value to ensure that the message is not processed multiple times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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