This Node.js learning project focuses on understanding RabbitMQ microservices. In
this project, I have developed three simple services which are responsible for
authentication
, product management
, and order management
.
- The
authentication
service is responsible for user register and login processes. - The
product
service is responsible for product creation and buying processes. - The
order
service is responsible for order creation processes.
The product
and order
services, process and connect to each other through RabbitMQ
queues.
Before running the project, make sure you have the following installed:
To set up RabbitMQ using Docker, run the following command in your terminal:
docker run -d -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.12-management
This command pulls the RabbitMQ Docker image and starts a container with RabbitMQ running. The RabbitMQ management console will be accessible at http://localhost:15672 (username: guest, password: guest).
-
Clone the repository:
git clone https://github.com/saeedNW/rabbitmq-microservice.git
-
Navigate to the project directory:
cd rabbitmq-microservice
-
Install project dependencies:
npm install
-
Ensure RabbitMQ is running using Docker (as specified in the "Setting Up RabbitMQ with Docker" section).
-
Follow the instructions for testing each service as described in the "Instructions for Testing Each service" section.
To start and use the auth
service follow these steps:
-
Open a new terminal instants and navigate to auth service directory
cd auth-service/
-
Install project dependencies:
npm install
-
Start authenticate service:
npm run dev
After starting the authentication service you can use the postman collection file in the project root directory to create a user and login to system.
The order service is responsible for managing order queue so the only thing you need to do for it is to run it and let it be.
To start the order
service follow theses steps:
-
Open a new terminal instants and navigate to order service directory
cd order-service/
-
Install project dependencies:
npm install
-
Start order service:
npm run dev
To start and use the product
service follow these steps:
-
Open a new terminal instants and navigate to product service directory
cd product-service/
-
Install project dependencies:
npm install
-
Start product service:
npm run dev
After starting the product service you can use the postman collection file in the project root directory to create and buy a product. After registering a buy request you can start monitoring the order and product services terminal to see the result of RabbitMQ processes.
You can also monitor the process by opening the RabbitMQ manager web page in http://localhost:15672 (username: guest, password: guest).
We would like to thank the following individuals who have contributed to the development of this project:
Erfan Yousefi - Supervisor and instructor of the node.js programming course