This repository provides simple examples of using message queues in Node.js with various message brokers, including RabbitMQ, Apache Kafka, AWS SQS, and Redis.
Follow these steps to run the examples:
- Clone the repository:
git clone https://github.com/ExorTek/nodejs-message-queue-examples.git cd nodejs-message-queue-examples - Install the dependencies:
OR
npm install
yarn install
- Run the examples:
npm run start:rabbitmq
npm run start:kafka
npm run start:sqs
ORnpm run start:redis
yarn start:rabbitmq
yarn start:kafka
yarn start:sqs
yarn start:redis
- Navigate to the
rabbitmqdirectory:cd rabbitmq - Start the RabbitMQ container:
docker-compose up
- Navigate to the
kafkadirectory:cd apache-kafka - Start the Apache Kafka container:
docker-compose up
- Navigate to the
redisdirectory:cd redis - Start the Redis container:
docker-compose up
For AWS SQS, ensure that you have your AWS credentials configured. You can use the AWS CLI to configure your credentials:
aws configureThe aws configure command will prompt you to enter your AWS Access Key ID, Secret Access Key, region, and output format. Make sure to use the same region where your SQS queue is located.
To create an SQS queue, you can use the AWS Management Console or the AWS CLI. For example, to create a FIFO queue using the AWS CLI, run:
aws sqs create-queue --queue-name orderQueue.fifo --attributes FifoQueue=true- Ensure that you have Docker and Docker Compose installed on your machine to use the Docker setup.
- The examples assume that you have the necessary permissions and resources configured for each message broker.
- If you encounter any issues, please check the respective message broker's documentation or raise an issue in this repository.