Not All DLQ Messages Are Alike

· 243 words · 2 minute read

I have messages being placed in a Dead Letter Queue (DLQ) that I created. The AWS Lambda Function that processed these messages failed the messages more than the allowed number of times, and were therefore put into the DLQ.

According to the Lambda Docs:

Lambda sends the event to the dead-letter queue as-is, with additional
information in attributes.

And there should be some Attributes on the message:

  • RequestID (string)
  • ErrorCode (Number)
  • ErrorMessage (string)

However, I don’t see those attributes. Also, when I look at my Function Configuration in the AWS Console (Configuration > Asynchronous invocation), it doesn’t indicate that there is a Dead-letter queue service. Which is odd, because the messages ended up in my DLQ regardless…

As it turns out, my DLQ is populated by another SQS Queue. My Lambda is configured to be triggered by an SQS Queue and read large batches of messages. On failure, the Lambda returns the messages in the batch back to the source queue.

The source queue is configured with a DLQ. I had configured my source queue to have it’s own DLQ. So my Lambda isn’t putting messages into the DLQ directly. Rather, it’s returning messages to the source queue with an incremented Receive Count attribute, and the source queue moved the messages to the DLQ when that count crossed the set threshold.

I should’ve read the terraform more closely, because as one might expect, yeah, the SQS Queue has the DLQ configuration on it…