AWS SQS FIFO 队列:队列应该启用 ContentBasedDeduplication 还是明确提供 MessageDeduplicationId?

AWS SQS FIFO Queue: The queue should either have ContentBasedDeduplication enabled or MessageDeduplicationId provided explicitly?

当我尝试使用 AWS CLI 向我的 FIFO SQS 添加消息时,我得到:

An error occurred (InvalidParameterValue) when calling the SendMessage operation: The queue should either have ContentBasedDeduplication enabled or MessageDeduplicationId provided explicitly

我的要求:

C:\Windows\system32>aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/307125934878/myqueue.fifo --message-body "hello world" --region us-east-1 --message-group-id 3

我该如何解决这个问题?

您必须为您的队列提供 --message-deduplication-id 或启用 ContentBasedDeduplication

You may provide a MessageDeduplicationId explicitly. If you aren't able to provide a MessageDeduplicationId and you enable ContentBasedDeduplication for your queue, Amazon SQS uses a SHA-256 hash to generate the MessageDeduplicationId using the body of the message (but not the attributes of the message).

deduplication ID是:

the token used for deduplication of sent messages. If a message with a particular message deduplication ID is sent successfully, any messages sent with the same message deduplication ID are accepted successfully but aren't delivered during the 5-minute deduplication interval.

对于现有队列,您可以在其Configuration 选项中启用它: