I am trying to read all the messages from a SQS ,aggregate all those msgs and store them as a single JSON file to S3 bucket, using lambda Java SDK?
Following Steps are involved in my implementation
Create a Standard SQS and send 500 messages to that SQS
Write a lambda read all the messages from that SQS using while loop(until message count becomes zero)
After reading all the messages from that SQS, now this lambda will have to aggregate all those received messages in to an ArrayList and convert the arraylist as a single JSON file and store this JSON file at a S3 bucket
now i am stuck at step 3, as AWS spans out multiple lambda instances while reading the SQS messages, hence i am unable to aggregate the received messages at one ArrayList, should i use Dynamo DB to aggregate all the messages and create a single JSON file and store in S3 bucket?
Please suggest a solution to resolve this problem
Thanks, Sundar
Set the ReservedConcurrentExecutions
attribute in your Lambda function to 1, therefore avoiding multiple instances to spin up.