Learn how to build a reliable, scalable messaging system in Node.js by leveraging AWS Simple Queue Service (SQS) and Simple Notification Service (SNS).
This repository contains the code for the tutorial: AWS SQS and SNS Node JS tutorial: Integrating AWS SQS and SNS in a NestJS Application with TypeScript by Mobisoft - App Development Company, Houston
To run the project locally:
- Clone the repository:
git clone https://github.com/mobisoftinfotech/sqs-sns-with-nest.git
- Navigate to the project directory:
cd sqs-sns-with-nest
- Install the dependencies:
npm install
- Set up environment variables:
AWS_ACCESS_KEY_ID=<Your AWS Access Key> AWS_SECRET_ACCESS_KEY=<Your AWS Secret Key> AWS_REGION=<Your AWS Region> SNS_TOPIC_ARN=<Your SNS Topic ARN> SQS_QUEUE_URL=<Your SQS queue URL>
- Start the development server:
npm start
The application should now be running on http://localhost:3000.
You can test the integration using a POST request to publish a message to SNS Or SQS:
- URL:
http://localhost:3000/sns/publish
- Method:
POST
{ "message": "Test SNS Message" }
Upon successful execution, you will receive a confirmation of the message being published to the SNS topic and sqs-consumer will consume the message and trigger handleMessage function also processed message entry will be saved in sqs_message table.
-
URL:
http://localhost:3000/sqs/publish
-
Method:
POST
{ "message": "Test SQS Message" }
Upon successful execution, you will receive a confirmation of the message being published to the SQS topic and sqs-consumer will consume the message and trigger handleMessage function also processed message entry will be saved in sqs_message table.
- Integration of SQS and SNS with Nest JS.
- Integration of sqs-consumer package for SQS messages polling
- Integration of SQLite DB to save processed messages
Enjoy exploring SQS and SNS with Nest JS!