- Newest
- Most votes
- Most comments
After further investigation, it is indeed related with my filter but not the one in my example. I also have another lambda function consuming messages from the same queue with a different filter. I believe this is what was happening:
Lambda Event Filter deletes messages from the Queue when the message do not match the filter criteria. If a queue has multiple lambda consumers with different event filters, there is a data loss when a filter which would match only one consumer was deleted by the other one because of a filter mismatch. It was hard to debug as there is no clear indication of who removed a message and why.
Hello.
How did you determine that Lambda has fewer invocations than SQS messages?
If you look at the Lambda CloudWatch logs, are there any logs that were processed for SQS messages?
Hello Riku
I checked the invocation count metric from cloudwatch and compared it with the messages recieved/deleted from sqs.
The most obvious suspect is the filter that you use. Could it be that not all message match the filter? If this is the case, messages that do not fit the filter are discarded and the function is not invoked.
Another, not so likely, suspect is the Delay param. When you send a message it will not be available for consumption for 10 seconds. Could it be that you did not wait enough time to see if the function is invoked?
Thanks Uri, your answer pointed me towards the correct direction. Added some details below about my findings.
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
You should never use more than once consumer on a queue. If you need more than one, send the message to SNS or EventBridge to distribute the message to multiple queues and then use a single consumer on each queue. If you only need some of the messages, use an appropriate filer on SNS/EventBridge to each queue.