How to receive a notification from AWS SQS when a new message is added to the queue

Viewed 1784

I trying to set up an SQS queue from AWS, my goal is

  1. Receive notification from an sns topic which is basically coming from amazon market place.
  2. When a new message comes in i need to notify my application that a new message is received along with the message or at least a notification that there is a new message.

Is there a way to achieve this? from documentation i could see that we can receive a message using the sdk, and i am using Node js, Express, link to amazon sdk-javaScript for sqs. should i keep on checking the sqs with a time interval ? there should be a better way i believe.

1 Answers

One option is to set up an Elastic Beanstalk worker-type env that hooks up to that SQS queue. When you create a worker-type beanstalk env (and you can choose Node there), you can specify which queue it consumes and what is the HTTP path that SQS will post the new messages to (an expressjs POST handler or something). It makes consuming the queue a bit easier, you either return 200 to destroy the message, or throw from that POST to put it back on the queue to retry or dead-letter it.

Related