AWS SQS FIFO 队列:无法在单个 运行 中使用循环发送消息

AWS SQS FIFO QUEUE: Unable to send message using loop in single run

我正在使用 AWS SQS 服务,目前正在尝试将消息插入队列中,我成功地插入了第一条消息,但无法使用循环插入第二条消息... returns相同的消息 ID 和序列号

MessageId: '****-a938-4fdc-abed-2efb1e302a2a', 序列号:'18848*******2174575616'

任何人都可以帮助我下面是我正在使用的代码:-

function insertMessage(data){
    var sqs = new AWS.SQS({apiVersion: '2012-11-05'});

        var params = {

           MessageGroupId:data.messageGroupId,
           MessageAttributes: {
                "operation": {
                    DataType: "String",
                    StringValue: "insert_comment"
                },
                "comment_id": {
                    DataType: "Number",
                    StringValue: ""+data.comment_id+""
                },
                "timestamp": {
                    DataType: "String",
                    StringValue: ""+data.created_on+""
                }
            },
            MessageBody: "New comment send ",

            QueueUrl: "******"
        };
        //console.log(params);
        sqs.sendMessage(params, function (err, data) {
            if (err) {
                console.log("Error", err);
                callback(err);
            } else {
                console.log("Success", data.MessageId);
                callback(data);
            }
        });
}

我正在循环调用上面的函数。

每次我在回调中得到相同的 MessageId 和 SequenceNumber 作为响应。

{ ResponseMetadata: { RequestId: '762a88d4-****-5298-***-dd3cb27f7dc1' },
  MD5OfMessageBody: '33d9f3a9*****bad5f72014ea836062',
  MD5OfMessageAttributes: '*****af0c13771494a53fdb2',
  MessageId: '*****-****-4fdc-abed-2efb1e302a2a',
  SequenceNumber: '188******174575616'

}

第二条消息和第一条消息一样吗?您不能将重复的消息放入 FIFO 队列中。

显然您没有添加 MessageDeduplicationId 属性,该属性指示启用了基于内容的复制。在这种情况下,MessageDeduplicationId 是根据邮件正文内容哈希自动为您生成的。此处,应用 5 分钟重复数据删除间隔。如果您想将具有相同消息正文且在重复数据删除间隔内的消息添加到队列中,则需要为每条消息生成唯一的 MessageDeduplicationId

References

If multiple messages are sent in succession to a FIFO queue, each with a distinct message deduplication ID, Amazon SQS stores the messages and acknowledges the transmission. Then, each message can be received and processed in the exact order in which the messages were transmitted.

MessageDeduplicationId

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.

去重配置

Enable content-based deduplication. This instructs Amazon SQS to use a SHA-256 hash to generate the message deduplication ID using the body of the message—but not the attributes of the message