This repository contains three microservices for an order application using RabbitMQ for communication. The services included are general-service, order-service, and payment-service, all built with Node.js and Express.js.
order-app-rabbitmq/
general-service/
order-service/
payment-service/
- Node.js 14.x
- Express.js
- RabbitMQ
-
Clone the repository:
git clone https://github.com/your-username/order-app-rabbitmq.git cd order-app-rabbitmq
-
Install dependencies for each service:
cd general-service npm install cd ../order-service npm install cd ../payment-service npm install
Each service requires environment variables to be configured. Create a .env
file in each service folder with the following variables:
PORT=3000
AMQP_URI=your_rabbitmq_uri
...
PORT=3001
AMQP_URI=your_rabbitmq_uri
GENERAL_SERVICE_URL=
...
PORT=3002
AMQP_URI=your_rabbitmq_uri
ORDER_SERVICE_URL=
GENERAL_SERVICE_URL=
...
To start the services, you must run the order-service first, followed by the general-service and payment-service.
-
Start the order-service:
cd order-service npm start
-
Start the general-service:
cd ../general-service npm start
-
Start the payment-service:
cd ../payment-service npm start
The order-service must be running before starting the general-service or payment-service to ensure proper communication between services. After starting the services, you can make API requests to the services using their respective ports.
Feel free to submit issues or pull requests.
This project is licensed under the MIT License.