を文書化されています。 SQS Dead Letter queue setupを読み、私の例を参照することができます。コーディングなしでAWS SQSコンソールを使用して、まったく同じことを行うことができます。
import boto3
sqs = boto3.client("sqs")
# I want to "lock" my queue for 5 minutes to allow my process have time to
# complete the task and delete the message afterwards.
response = sqs.create_queue(
QueueName="foo",
Attributes= {
"VisibilityTimeout" : "300"
}
)
# create a queue to store the "dead letter message"
dlq_response = sqs.create_queue(
QueueName="dlq-foo",
Attributes= {
"VisibilityTimeout" : "300"
}
)
queue_url = response["QueueUrl"]
# Attach RedrivePolicy to drive message to dead letter queue
# I want to make sure the message only read 1 time. Assume the program crash
# if it is not deleted.
# deadLetterTargetArn : You must specify the queue exact region name,
# exact Account name(replace 1234567890) and your dead letter queue name dlq-foo
sqs.set_queue_attributes(
QueueUrl = queue_url,
Attributes = {
"RedrivePolicy" : """{
"maxReceiveCount" : "1" ,
"deadLetterTargetArn" : "arn:aws:sqs:<region-name>:1234567890:dlq-foo"
}"""
}
)
注:RedrivePolicyは、リテラル文字列(NOT辞書)にのみアクセスします。しかし、doucumentationが指摘しているように、あなたはそこに "辞書のような"値を入れ、それを文字列としてフォーマットする必要があります。あなたはdictを文字列に変換するためにstr(dict())を使うことができます。私はPythonの三重引用符を使って分かりやすくしています。
あなたが求めているのは、まさにSQSのことです。あなたはあなたが持っている問題についてより具体的にする必要があります。 –