SQS not sending messages to dead letter queue

I have a Localstack Docker container. At startup I create a queue and a dead-letter queue

The queue is created like this:

 aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name my-queue \
    --attributes '{
      "MessageRetentionPeriod": "180",
      "RedrivePolicy": "{\"deadLetterTargetArn\":\"http://localhost:4566/000000000000/my-dlq-queue\",\"maxReceiveCount\":\"3\"}",
      "VisibilityTimeout": "30"

My application polls the queue and processes the messages from it. It’s supposed to send the messages to ther DLQ after the application has failed to process the message 3 times.
Everytime the message is put back in the queue, the message Visibility is randomised (up to 2 minutes)

Everything happens according to plan until the message has been received 3 times.

It then just stays in-flight - I can see 1 message in ApproximateNumberOfMessagesNotVisible when calling

aws --endpoint-url=http://localhost:4566 sqs get-queue-attributes --attribute-name All --queue-url=http://localhost:4566/000000000000/my-queue

The messages never end up in the dead letter queue.

When the app is run in a real AWS environment, the messages do end up in the DLQ.

What could be the problem here?


I have worked it out - the ARN format of the DLQ is incorrect, it should be

1 Like

Hi @Oxxxie β€” Glad it worked! Please let us know if you encounter any further issues :raised_hands: