SNS SQS 扇出架构

SNS SQS fanout architecture

查看 the documentation 这个模式,它说

The Amazon SQS message contains the subject and message that were published to the topic along with metadata about the message in a JSON document

所以当我发布到 SNS 主题时,转发的唯一属性是通知的主题和默认参数?这是否意味着如果我想将 json 发送到我的队列,我必须将其字符串化并将其设置为通知的默认参数?

如果您查看 examples section of the SNS docs,您会看到有选项可以将消息指定为电子邮件、https 等,包括 sqs。如果你想发送关于通知的队列特定信息,那么你可以把它放在那里,它会覆盖默认参数。 node

中的一个例子
sns.publish({
  TopicArn: topicArn,
  MessageStructure: 'json',
  Message: JSON.stringify({
    default: JSON.stringify(defaultMessageJson),
    sqs: JSON.stringify(sqsMessageJson)
  })
})