19/01/2022 - AWS
Bu örnekte, 3 denemeden sonra mesajları AWS SQS kaynak kuyruğundan DLQ'ya taşıyacağız. İletiler herhangi bir nedenle işlenmezse yeniden denemeler gerçekleşir. Mesaj, her deneme arasında her 30 saniyede bir görünür olacaktır.
$ aws --profile localstack --endpoint-url http://localhost:4566 sqs create-queue \
--queue-name work-queue.dlq
$ aws --profile localstack --endpoint-url http://localhost:4566 sqs create-queue \
--queue-name work-queue \
--attributes '{"RedrivePolicy":"{\"deadLetterTargetArn\":\"arn:aws:sqs:eu-west-1:000000000000:work-queue.dlq\",\"maxReceiveCount\":\"3\"}"}'
$ aws --profile localstack --endpoint-url http://localhost:4566 sqs send-message \
--queue-url http://localhost:4566/000000000000/work-queue \
--message-body '{"key":"val"}'
Mesajları 3 kez tüketmeye çalışıyorum.
$ aws --profile localstack --endpoint-url http://localhost:4566 sqs receive-message \
--queue-url http://localhost:4566/000000000000/work-queue \
--attribute-names All --message-attribute-names All --max-number-of-messages 10
$ aws --profile localstack --endpoint-url http://localhost:4566 sqs receive-message \
--queue-url http://localhost:4566/000000000000/work-queue \
--attribute-names All --message-attribute-names All --max-number-of-messages 10
$ aws --profile localstack --endpoint-url http://localhost:4566 sqs receive-message \
--queue-url http://localhost:4566/000000000000/work-queue \
--attribute-names All --message-attribute-names All --max-number-of-messages 10
Mesaj şimdi DLQ'da olmalıdır.
$ aws --profile localstack --endpoint-url http://localhost:4566 sqs receive-message \
--queue-url http://localhost:4566/000000000000/work-queue.dlq \
--attribute-names All --message-attribute-names All --max-number-of-messages 10