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.
Before running the code, make sure you have the following installed:
- Node.js
- npm (Node Package Manager)
- RabbitMQ server
- CloudAMQP account (for using CloudAMQP)
-
Clone the repository:
git clone https://github.com/AdityaBVerma/LavinMQ
-
Install dependencies for both producer and consumer:
npm install
-
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. -
Create Producer.js and Consumer.js
touch Producer.js
touch Consumer.js
To run the producer:
-
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.
-
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.
Contributions are welcome! Feel free to open issues or submit pull requests.