I am trying to trigger my lambda function from SQS delay queue and it is triggering lambda but no message in queue. Even when I check on aws console there is a message delay and when that delay time is over. It trigger my lambda function but when my lambda try to get the list of messages it shows empty list. The other thing is when I remove the lambda trigger after that whenever I send a message to queue it shows message available after the delay time. So it's working as expected without adding a trigger to lambda but when I add trigger my lambda is not receiving any message to process.
I have tried various things but nothing worked out. my Default Visibility Timeout: 30seconds and Receive Message Wait Time: 0 seconds and Delivery Delay: 10 seconds.
Using below code to fetch the messages from sqs and it always return empty list :
final ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(SQS_URL);
final List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
I am new to aws and don't know what to do, due to this issue stuck in a deadlock. Please help.
If you have configured the Amazon SQS queue to trigger an AWS Lambda function, then the function should not call ReceiveMessage().
Instead, the message is automatically taken from the SQS queue and is passed to the Lambda function via the event parameter.
For sample code, see: Sample Amazon SQS Function Code - AWS Lambda
The Lambda function should loop through the messages passed to the function. When the function ends, the messages will automatically be deleted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With