amazon-web-services - AWS SNS - how should I be sending message data, MessageAttributes?
问题描述
I'm building an application that enables clients to book appointments with service providers. I'm using SNS -> SQS -> Lambda to process various emails that need to be sent when booking an appointment. IE I currently send an SNS message like so (in node.js):
await sns.publish({
Message: 'booking-request',
TopicArn: process.env.AWS_BOOKING_REQUEST_TOPIC_ARN,
MessageAttributes: {
artistEmail: SNSMF.string(artist.email),
artistName: SNSMF.string(artist.name),
clientEmail: SNSMF.string(req.body.email),
clientName: SNSMF.string(`${req.body.firstName} ${req.body.lastName}`),
date: SNSMF.string(moment(req.body.date).tz(studio.timeZone).format())
}
}).promise();
This all works fine, but I'm using MessageAttributes
to pass the pertinent appointment details so my notifications layer can send the proper emails.
My main questions is, am I using MessageAttributes in the proper way, or is there a better way to pass all of this data? Should the data be the message itself? I ask because I believe that you can only have 10 MessageAttributes and I'm going to run into a limit with the appointment details (currently collecting about 10-12 data points about the appointment that I want to include in the emails). Any ideas? Thank you!
解决方案
通常,您希望传递的“主要”信息将在Body
消息中。使用 JSON 传递各种类型的信息是很常见的。
MessageAttributes
通常是关于消息本身而不是消息的内容,例如时间戳、优先级和用户信息。
鉴于您的要求,我将您的数据放入Body
(例如 JSON 中)将避免达到限制并且也将更具可扩展性。
推荐阅读
- django - 如何基于父模型为所有子模型生成休息视图集
- angular - 奇怪的obj标志无缘无故出现
- android - 如何修复“您需要 MANAGE_USERS 或 CREATE_USERS 权限才能:获取与用户 0 相关的配置文件”错误?
- java - 如何避免使用 Hibernate 从 VARCHAR 到 VARCHAR2 的隐式类型转换?
- javascript - 登录时在firebase中添加首次注册用户关系的更好方法是什么?
- oracle-adf - ADF 中的 ApplicationModule 定义类代码为空
- python - 在函数内部未定义值
- python - 使用 os.walk() 循环文件并打开它们
- android - Android PresetReverb 不起作用(Kotlin)
- jquery - 删除aspnet核心mvc中的数据后如何使用jquery延迟3000秒重定向页面