AWS SNS Publish:无法为Node.js的FIFO发布消息

时间:2020-11-03 07:40:20

标签: amazon-web-services amazon-sqs amazon-sns

发布消息的功能


 this.sns = new SNS({ apiVersion: '2010-03-31', region: <region> });

    async publishMessage() {
        try {
            const params = {
            MessageGroupId: 'test',
            MessageDeduplicationId: uuidv4(),
            Message: 'test',
            TopicArn: 'arn:aws:sns:<region>:<accountID>:item-dev-topic.fifo',
        };

            const res = await this.sns.listTopics().promise();
            // Works : this returns the topic which I plan to use

            const response = await this.sns.publish(params).promise();
            // Fails : this line gives error saying multiple invalid param (MessageGroupId, MessageDeduplicationId) 

            console.log(response);
            return res;
        } 

       catch (error) {
            throw new Error(error);
        }
    }

错误:说出多个无效参数(MessageGroupId,MessageDeduplicationId) 当我删除此参数时,它表示那些参数丢失,而当我添加这些参数时,它表示无效参数。

观察:

  1. 这适用于非Fifo的SNS主题
  2. 列表主题适用于Fifo和Standard SNS主题,其中包括我必需的SNS主题

1 个答案:

答案 0 :(得分:1)

将AWS开发工具包升级到最新版本 解决了这一重大问题

SDK版本出现错误:v2.744.0

升级到 v2.784.0 可以解决上述问题

相关问题