AWS SNS 发布:无法发布 Node.js 的 FIFO 消息
AWS SNS Publish : Not able to publish message for FIFO for Node.js
消息发布功能
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)
当我删除此参数时,它说缺少这些参数,而当我添加这些参数时,它说无效参数。
观察:
- 这适用于不是 Fifo 的 SNS 主题
- List Topics 适用于 Fifo 和 Standard SNS 主题,它包括我需要的 SNS 主题
正在将 AWS SDK 升级到最新版本
修复了这个重大问题
出现错误的SDK版本:v2.744.0
升级到 v2.784.0 解决了上述问题
消息发布功能
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) 当我删除此参数时,它说缺少这些参数,而当我添加这些参数时,它说无效参数。
观察:
- 这适用于不是 Fifo 的 SNS 主题
- List Topics 适用于 Fifo 和 Standard SNS 主题,它包括我需要的 SNS 主题
正在将 AWS SDK 升级到最新版本 修复了这个重大问题
出现错误的SDK版本:v2.744.0
升级到 v2.784.0 解决了上述问题