This project demonstrates an RPC-based messaging system using RabbitMQ and Node.js. It integrates RabbitMQ with an Express.js HTTP server, allowing HTTP clients to send requests and receive responses.
- Asynchronous RPC Pattern: Processes messages via RabbitMQ and responds to HTTP requests.
- Request-Response Handling: Ensures each HTTP request gets a unique RabbitMQ response.
- Scalable Design: Supports multiple consumers and concurrent HTTP requests.
- Docker and Docker Compose installed.
- Node.js (v14 or later) and npm installed.
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Start RabbitMQ using Docker Compose:
make docker-up
-
Install Node.js dependencies:
npm install
-
Setup env
cp .env.example .env
Access RabbitMQ Management UI:
- URL: http://localhost:15672
- Username:
guest
- Password:
guest
-
Start RPC Server:
make start-rpc
-
Start HTTP Server:
make start-http
Send a test HTTP request to the /process
endpoint:
curl -X POST -H "Content-Type: application/json" -d '{"input": "foo"}' http://localhost:3000/process
Expected Response:
{
"result": "foo bar"
}
Run the load test script to benchmark the system:
node load_test.js
Stop all services and clean up resources:
make clean
- Increase RabbitMQ consumers by running multiple
rpc_server.js
instances. - Use a load balancer (e.g., NGINX) to scale HTTP servers.
- Monitor RabbitMQ queue size and latency during peak loads.