2
votes

I have structure similar to this

SQS -> Lambda -> DLQ

When Lambda is invoked asynchronously like below then failure messages are getting added successfully to DLQ.

$ aws lambda invoke --function-name my-function --invocation-type Event --payload '{ "key": "value" }' response.json

But when lambda gets triggered on adding new messages to SQS then on failure, messages doesn't store in DLQ.

I found that events triggered when new message published to SQS are synchronous in nature.

Lambda polls the queue and invokes your function synchronously with an event that contains queue messages.

Reference - https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html.

So I want either-

  1. SQS event trigger invoke lambda asynchronously

or

  1. Messages gets stored in DLQ on synchronous invocation of Lambda as well.
1
Please checkout this answer for understanding how to add destination on failure for synchronous invocation on lambda: stackoverflow.com/a/63531865/8656417PodGen4

1 Answers

1
votes
  1. DLQ is used not to store error messages but to store failed events, that can be handled again later.
  2. CloudWatch is used to store and show logs (including errors) for Lambda and any other AWS service.
  3. The idea behind SQS triggering Lambda is that in case of Lambda failure, the event will be handled again by Lambda later.
    It's the same idea as DLQ but implemented differently.