向包含 MessageGroupId 和 MessageDeduplicationId 的标准 SNS 主题发送消息将永远不会被收到?

问题描述 投票:0回答:1

 我创建了一个标准 SNS 主题并向其添加电子邮件订阅。我向这个主题发送了这样的消息:

const command = new PublishBatchCommand({
      TopicArn: "myStandardTopicArn",
      PublishBatchRequestEntries: messages.map(message => {
        return {
          MessageGroupId: "someGroupID",
          MessageDeduplicationId: getUUID(),
          Id: getUUID(),
          Message: JSON.stringify(message.data),
 
        };
      }),
    });

    try {
      await this.snsClient.send(command);
    } catch (e) {
      // there is no error
      throw e;
    }

没有抛出异常,但我也没有收到任何电子邮件通知。

一旦我删除

MessageGroupId
MessageDeduplicationId
,它就可以工作了。

这是预期的行为吗?我希望得到一个例外,或者只是忽略这两个属性并发送电子邮件通知。

如果这是预期的行为,文档中是否有相关内容?我无法在here找到任何关于此的信息。我假设这些属性适用于 FIFO 主题,但我在文档中也找不到任何内容专门告诉您在发送到标准主题时不要使用它们

我也无法在文档中找到任何信息,说明对于

FIFO
主题,只有
SQS
订阅协议可用...

amazon-web-services amazon-sns
1个回答
0
投票

MessageDeduplicationId 和 MessageGroupId 关键字仅为 FIFO 主题保留。

https://docs.aws.amazon.com/cli/latest/reference/sns/publish.html

如果您不小心将这些保留关键字与标准 SNS 主题一起使用,则应抛出类似于以下内容的异常:

An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: MessageGroupId Reason: The request includes MessageGroupId parameter that is not valid for this topic type

 An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: MessageDeduplicationId Reason: The request includes MessageDeduplicationId parameter that is not valid for this topic type

© www.soinside.com 2019 - 2024. All rights reserved.