Expected behavior
Once we have consumed a message from an SQS queue upto its maxReceiveCount
and not acknowledged its receipt by deleting it from the queue, the message should be pushed to its DLQ. If the DLQ has a DelaySeconds
of 0 seconds(Default) then the message should be immediately available for consumption
Behavior in test
Code should be able to read message from DLQ immediately after it is verified that the condition for DLQ(maxReceiveCount
reached) has been met. Though with the current test, reading message from DLQ returns no messages. But after reading the message from DLQ through AWS CLI, the message is visible. This points to the fact that the DelaySeconds
attribute is not enforced. This can be either an issue on AWS side which is reflected on Localstack or an issue on the Localstack.
AWS SQS queue creation
#!/bin/sh
echo "Init localstack sqs"
export AWS_SECRET_ACCESS_KEY="FAKE"
export AWS_ACCESS_KEY_ID="FAKE"
export AWS_DEFAULT_REGION=us-east-1
# For demo purposes, let us create a dead letter queue as well
awslocal sqs --endpoint-url "http://localhost:44566" create-queue --queue-name sample-queue-dlq --attributes '{"MessageRetentionPeriod": "259200", "DelaySeconds": "0"}'
awslocal sqs --endpoint-url "http://localhost:44566" create-queue --queue-name sample-queue --attributes '{"RedrivePolicy": "{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:000000000000:sample-queue-dlq\",\"maxReceiveCount\":\"3\"}", "VisibilityTimeout": "1"}'
Steps to reproduce
Code repository: GitHub - varunu28/sqs-dlq-demo
Test file: SampleDlqDelayTest.java