2

I have a lambda setup that has event source configured with 5 different SQS queues. Now, if the batch size of the lambda is configured to be 10, will the 10 records in SQSEvent in the lambda handler will be from the same queue or can the 10 records in the batch be from any of the 5 queues ?

2
  • 1
    I have not come across any documentation for that case but I would be pretty sure, that all the records are from the same queue. Because combining messages from multiples queues would be extra work the intermediary service invoking the lambdas. It simply polls a queue and invokes the lambda, there is not that much logic in there. Note that even if the batch size is 10 and there are 10 records chances are you will not get a batch of 10 messages but smaller batches. Only if you have very man messages in the queues does the batches actually take effect. (unless you configure a batch window) Commented Jan 15, 2021 at 9:51
  • Each queue has its own URL. If you want to get the messages from different queues you also need to call the sqs.receiveMessage method 5 times each with a specific queue url. Commented Jan 15, 2021 at 13:08

1 Answer 1

1

The behavior is undocumented, but it's almost certainly the case that the Lambda service will batch events from one, and only, queue in a single Lambda invocation.

That said, if it's critical to your application that you be able to distinguish one queue source from another, then either:

  1. create one Lambda handler per queue (it could simply call your common handler function with an indicator of which queue was the source), or
  2. check the value of the eventSourceARN in each record in the event
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.