4

I have set up a dead letter queue in AWS Lambda configuration, to handle failed events. But when I tried sending an erroneous record (of size ~1KB), it is not getting sent to DLQ.

Below are the Steps I followed:-

  1. Sent invalid record from aws cli to kinesis stream.

  2. Lambda function polled the record from stream and tried processing. And it resulted into failure due to malformed input.

  3. Checked Lambda function cloud watch logs to confirm that processing has resulted into error.
  4. Checked dead letter errors number in Lambda's cloud watch log but it is still 0. Also verified DLQ through AWS Console, where available messages is still 0.

Configurations in AWS Lambda for asynchronous invocation:

  • Max age of event = 1 min,
  • Retry attempts = 1

Configuration of DLQ:

  • Delivery Delay: 0 seconds
  • Default Visibility Timeout: 30 seconds,
  • Maximum Message Size: 256 KB

Can someone explain what could be the possible reason for error messages not available in SQS?

Note : Lambda has required permissions to perform all operations on SQS. And there is no other consumer of SQS.

user3400887
  • 409
  • 1
  • 4
  • 18
  • Please check this answer for understanding how to configure destination on failure in event source mapping: https://stackoverflow.com/a/63531865/8656417 – PodGen4 Aug 22 '20 at 01:58

2 Answers2

9

Lambda reads data from Kinesis synchronously.
DLQ is used only for asynchronous invocations of Lambda.

nickolay.laptev
  • 2,253
  • 1
  • 21
  • 31
  • 1
    Thanks I was able to send events to SQS after updating destination Config in event source mapping. Sharing useful reference doc here: https://aws.amazon.com/blogs/compute/new-aws-lambda-controls-for-stream-processing-and-asynchronous-invocations/ – user3400887 Jan 29 '20 at 06:45
  • 1
    also applies when triggering lambdas from SQS. Lambdas are triggered sychronously and the DLQ setup within lambda async config won't do anything. – Stagg Feb 14 '20 at 12:48
0

This all depends on the response you are returning from the function. If the response is a failure with proper error code it will definitely get pushed in DLQ. can you remove the DLQ configuration and then check if the message appearing in the SQS after the visibility time.

Ngen CMS
  • 146
  • 1
  • 6
  • I'm handling the json exception and raise it. Is there anything else I need to do to mark function execution failed? Example snippet (python) try: payloadJson = json.loads(payload) except ValueError: print('Error while loading json') raise except: print('Unhandled exception') raise – user3400887 Jan 28 '20 at 04:53