A High-Performance Redis Simple Message Queue for Node.js
Key Features
- High-performance message processing
- Flexible producer/consumer model with multi-queue producers and consumers
- Different exchange types (Direct, Topic, FanOut) for publishing messages to one or multiple queues
- Two delivery models (Point-2-Point and Pub/Sub) with reliable delivery and configurable retry modes
- Three queuing strategies (FIFO, LIFO, Priority Queues)
- Message handler worker threads for sandboxing and performance improvement
- Message expiration and consumption timeout
- Queue rate limiting for controlling message consumption rates
- Built-in scheduler for delayed message delivery and repeating messages
- RESTful API and web UI for interacting with the message queue
- Support for ESM and CJS modules
Use Cases
- Managing background tasks, such as email sending or data processing.
- Efficiently scheduling and retrying tasks.
- Communication between multiple services in microservices architectures.
- Handling real-time events in gaming, IoT, or analytics systems.
Installation and Usage
To get started with RedisSMQ, you can install the library using npm:
npm i redis-smq@rc
Create a queue, produce a message, and consume it using the provided classes and methods:
// Creating a queue
const queue = new Queue();
queue.save('my_queue', EQueueType.LIFO_QUEUE, EQueueDeliveryModel.POINT_TO_POINT, (err) => {
if (err) console.error(err);
});
// Producing a message
const msg = new ProducibleMessage();
msg.setQueue('my_queue').setBody('Hello Word!');
producer.produce(msg, (err, ids) => {
if (err) console.error(err);
else console.log(`Produced message IDs are: ${ids.join(', ')}`);
});
// Consuming a message
const consumer = new Consumer();
const messageHandler = (msg, cb) => {
console.log(msg.body);
cb(); // Acknowledging
};
consumer.consume('my_queue', messageHandler, (err) => {
if (err) console.error(err);
});
Documentation
For more information, visit the RedisSMQ Docs.
Contributing
Interested in contributing to this project? Please check out our CONTRIBUTING.md.
License
RedisSMQ is released under the MIT License.