简体   繁体   中英

SNS SQS fanout architecture

Looking at the documentation for this pattern it says

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

So when I publish to an SNS topic, the only properties that are forwarded are the subject of the notification, and the default parameter? Does this mean if I want to send json to my queues I have to stringify it and set it as the default parameter of the notification?

If you check out the examples section of the SNS docs you can see there are options to specify messages to email, https, etc including sqs. If you want to send queue specific information on a notification then you can put it in there and it will overwrite the default parameter. An example in node

sns.publish({
  TopicArn: topicArn,
  MessageStructure: 'json',
  Message: JSON.stringify({
    default: JSON.stringify(defaultMessageJson),
    sqs: JSON.stringify(sqsMessageJson)
  })
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM