I want to send many messages to AWS SQS, so they can trigger a AWS Lambda function, but I want that the queue waits 3 seconds to dequeue each message and trigger the Lambda function.
I've tried by modifing the Delivery Delay, but it only has the delay by enqueuing a message, and it is "by message", so if I send 100 messages at the same time, they will wait the same time and instantly will be available all the 100 messages.
At the other hand I tried with Visibility timeout, but it only works when there are many consumers, other way, it won't work.
Here you can see how I'm getting nearly at the same time all the events (it just differ by some milliseconds)
To sum up, I'm looking for a way that AWS SQS could trigger a lambda with each message but waiting some seconds between each dequequing.
For more context:
I'm using a Standard Queue and I need the information that it's in the message but I have to wait, because the API services that I'll use have a very low rate limit.
One method would be:
1
. Reserved concurrency is the maximum number of concurrent instances you want to allocate to your function.1
. This ensures that only one message will be passed to the Lambda function on each invocation.sleep()
call to the Lambda function before it exits so that there is a delay between executions.The net result is that one message will be processed at a time and there will be a 3-second delay between messages being processed.