0

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!

Greg
  • 6,453
  • 9
  • 45
  • 61

1 Answers1

4

Normally, the 'main' information you wish to pass would be in the Body of the message. It is quite common the use JSON to pass various types of information.

MessageAttributes are normally something about the message itself rather than the content of the message, such as timestamps, priority and user information.

Given your requirements, I putting your data in the Body (eg in JSON) would avoid hitting limits and would also be more extensible.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Thans John. I ended up doing as you suggested, and JSON.stringify(...) and then parsing it in the handling code. Works great. Thanks! – Greg Aug 07 '18 at 02:41