AWS SQS FIFO队列:队列应该启用ContentBasedDeduplication或显式提供MessageDeduplicationId?

21

当我尝试使用 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

我该怎么解决这个问题?

1个回答

29
您需要为您的队列提供 --message-deduplication-id,或者启用 ContentBasedDeduplication

如果您无法提供 MessageDeduplicationId,并且您启用了队列的 ContentBasedDeduplication,则可以 显式地 提供一个 MessageDeduplicationId,否则 Amazon SQS 将使用消息正文(但不使用消息属性)生成基于 SHA-256 的哈希来生成 MessageDeduplicationId。

去重ID 是:

用于去重已发送消息的标记。 如果具有特定消息去重 ID 的消息发送成功,则具有相同消息去重 ID 的任何消息都会被成功接受,但在 5分钟 去重间隔期内不会传递。

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

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接