bulltrader-rabbitmq
v1.0.4
Published
This is a lightweight RabbitMQ library for Node.js that simplifies the process of interacting with RabbitMQ. It provides a simple interface for sending and receiving messages from RabbitMQ exchanges and queues.
Downloads
4
Readme
RabbitMQ Message Broker
This is a lightweight RabbitMQ library for Node.js that simplifies the process of interacting with RabbitMQ. It provides a simple interface for sending and receiving messages from RabbitMQ exchanges and queues.
Installation
To install the RabbitMQ Light Library, use npm:
npm install rabbitmq-message-broker
Usage
Sending Messages
// Import the RabbitMQ class
const { Rabbitmq, ExchangeDto, RouteDto } = require('rabbitmq-light-library');
// Create a new Rabbitmq instance
const rabbitmq = new Rabbitmq();
// Connect to the RabbitMQ server
await rabbitmq.connect();
// List of existing channels
let channels = await rabbitmq.getChannels();
// Get a specific channel
let channelName = await rabbitmq.getChannel('src', 'dst');
// List of existing Exchanges in the taken channel
let exchanges = await rabbitmq.getExchanges(channelName);
// List of existing Routes in the taken channel
let routes = await rabbitmq.getRoutes(channelName);
// Send a message
await rabbitmq.sendMessage('channelName', 'exchangeName', 'routeName', { your: 'data' });
// Receive a message
await rabbitmq.receiveMessage('channelName', 'routeName', (message) => {
console.log('Received message:', message);
// Add your message handling logic here
});
// Disconnect from the RabbitMQ server
await rabbitmq.disconnect();
Features
- Easy connection management with the RabbitMQ server
- Send and receive messages from RabbitMQ exchanges and queues
- Efficient handling of exchanges and routes
- Lightweight and easy-to-use interface for RabbitMQ interactions
Contributing
Contributions are welcome! If you have any suggestions, bug fixes, or new features to add, please feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.