Skip to content

Latest commit

 

History

History
77 lines (46 loc) · 1.55 KB

README.md

File metadata and controls

77 lines (46 loc) · 1.55 KB

RabbitMQ Producer-Consumer Setup

This repository contains code for setting up a producer-consumer architecture using RabbitMQ messaging broker. The setup consists of two components: a producer and a consumer, written in JavaScript with Node.js.

Prerequisites

Before running the code, make sure you have the following installed:

  • Node.js
  • npm (Node Package Manager)
  • RabbitMQ server
  • CloudAMQP account (for using CloudAMQP)

Installation

  1. Clone the repository:

    git clone https://github.com/AdityaBVerma/LavinMQ
  2. Install dependencies for both producer and consumer:

    npm install
  3. Set up environment variables:

    Create a .env file with the following content:

    CLOUDAMQP_URL=<your_cloudamqp_url>
    

    Replace <your_cloudamqp_url> with your CloudAMQP URL.

  4. Create Producer.js and Consumer.js

    touch Producer.js
    touch Consumer.js

Usage

Producer

To run the producer:

  1. Run the producer script:

    node Producer.js

The producer will connect to the RabbitMQ server specified in the environment variables, send messages to the queue, and then exit after a specified timeout.

Consumer

  1. Run the consumer script:

    node Consumer.js

The consumer will connect to the RabbitMQ server, listen for messages in the queue, process them, and acknowledge them after processing.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.