Java 8 here using the AWS Java SDK to write a Java lambda that should execute in response to a message being sent to an SQS queue.
Ideally, one-and-only-one lambda instance will be invoked/executed for each record sent to the SQS queue. So if 5 messages are sent to the queue, 5 lambdas will fire (or - depending on my lambda configuration - I may set a max # of concurrent lambdas in which case my expectation is that pending/unconsumed SQS messages would wait for the next available lambda).
This is not a hard requirement, just ideal.
I noticed that in the com.amazonaws.services.lambda.runtime.events.SqsEvent class, there is a getRecords() : List<SQSMessage> method which has me a bit concerned. To me, this implies that a single lambda instance may be fed more than 1 SQS message per execution, which again, goes against my desired behavior.
So I'm wondering if there is a way to configure the Lambda trigger such that it only ever fires once per SQS queue message, and also honors a "max # of concurrent Lambda instances" setting, making messages wait in SQS until a Lambda is ready. So as another example, say I have the max # of concurrent Lambdas set to three (3), and 5 messages get sent onto the queue at the same time. In this case, I would want 3 Lambdas to fire, each processing one of the 5 queued messages, and 2 of the 5 messages would be waiting for one of those 3 Lambdas to finish so another one could fire and pick them up.
Is this possible to do? Or does Lambda just "decide" (?) somehow on its own how many messages to submit to a given Lambda execution? If so, anybody know how this is decided?