Skip to content

RPC-based messaging system using RabbitMQ and Node.js. Checkout experiment/redis branch 🥵

Notifications You must be signed in to change notification settings

sachin-duhan/rabbitmq-wave

Folders and files

NameName
Last commit message
Last commit date
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024

Repository files navigation

README

RabbitMQ RPC with HTTP Interface

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.


Features

  • 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.

Prerequisites

  1. Docker and Docker Compose installed.
  2. Node.js (v14 or later) and npm installed.

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-folder>
  2. Start RabbitMQ using Docker Compose:

    make docker-up
  3. Install Node.js dependencies:

    npm install
  4. Setup env

    cp .env.example .env

RabbitMQ Login

Access RabbitMQ Management UI:


Usage

Start Servers

  1. Start RPC Server:

    make start-rpc
  2. Start HTTP Server:

    make start-http

Test Endpoint

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"
}

Load Testing

Run the load test script to benchmark the system:

node load_test.js

Cleanup

Stop all services and clean up resources:

make clean

Scaling Suggestions

  1. Increase RabbitMQ consumers by running multiple rpc_server.js instances.
  2. Use a load balancer (e.g., NGINX) to scale HTTP servers.
  3. Monitor RabbitMQ queue size and latency during peak loads.

About

RPC-based messaging system using RabbitMQ and Node.js. Checkout experiment/redis branch 🥵

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published