Aagam Doshi
Aagam Doshi

Reputation: 193

AWS SNS Publish : Not able to publish message for FIFO for Node.js

Function to publish message


 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);
        }
    }

Error : saying multiple invalid param (MessageGroupId, MessageDeduplicationId) When I remove this param it says those params are missing, and when I add these params it says invalid param.

Observations :

  1. This works for SNS topic which are not Fifo
  2. List Topics works for both Fifo and Standard SNS topics and it includes my required SNS topic

Upvotes: 1

Views: 2064

Answers (1)

Aagam Doshi
Aagam Doshi

Reputation: 193

Upgrading the AWS SDK to latest version fixed this breaking issue

SDK version which had the error : v2.744.0

Upgrading to v2.784.0 fixed the above issue

Upvotes: 2

Related Questions