Package Exports
- redis-smq
- redis-smq/dist/index.cjs
- redis-smq/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redis-smq) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
RedisSMQ
RedisSMQ is a Node.js library for queuing messages (aka jobs) and processing them asynchronously with consumers. Backed by Redis, it allows scaling up your application with ease of use.
Features
- High-performance message processing.
- Multi-Queue Producers & Multi-Queue Consumers: Offering flexible Producer/Consumer models, with focus on simplicity and without tons of features. This can make RedisSMQ an ideal message broker for your microservices.
- at-least-once/at-most-once Delivery: In case of failures, while delivering or processing a message, RedisSMQ can guaranty that the message will be not lost and redelivered again. When configured to do so, RedisSMQ can also ensure that the message is delivered at-most-once.
- Different Exchange Types: RedisSMQ offers 3 types of exchanges: Direct Exchange, Topic Exchange, and FanOut Exchange for publishing a message to one or multiple queues.
- FIFO queues, LIFO queues, and Reliable Priority Queues: Provides different queuing strategies that you may use depending on your needs and requirements.
- Message Expiration: Allowing a message to expire if it has not been delivered within a given amount of time.
- Message Consumption Timeout: Allowing to set up a timeout for consuming messages.
- Queue Rate Limiting: Allowing to control the rate at which the messages are consumed from a given queue.
- Scheduling Messages: Messages can be configured to be delayed, delivered for N times with an optional period between deliveries, and to be scheduled using CRON expressions.
- Multiplexing: A feature which allows message handlers to use a single redis connection to dequeue and consume messages.
- HTTP API: an HTTP interface is provided to interact with the MQ.
- Web UI: RedisSMQ can be managed also from your web browser.
- Logging: RedisSMQ comes with a built-in JSON logger, but can also use your application logger.
- Configurable: Many options and features can be configured.
- Multiple Redis clients: Depending on your preferences, RedisSMQ can use either node-redis v3, node-redis v4, or ioredis.
- Highly optimized: Strongly-typed and implemented using pure callbacks, with small memory footprint and no memory leaks. See Callback vs Promise vs Async/Await benchmarks.
RedisSMQ Use Case: Multi-Queue Producers & Multi-Queue Consumers
What's new?
🚀 RedisSMQ v8 is coming soon!
Installation
Currently, RedisSMQ is going under heavy development. Pre-releases at any time may introduce new commits with breaking changes. To view the latest release reference see RedisSMQ v7.2.3
npm i redis-smq@rc
Considerations:
- Minimal Node.js version is >= 18 (RedisSMQ is tested under current active LTS and maintenance LTS Node.js releases).
- Minimal Redis server version is 4.0.0.
Usage
RedisSMQ provides 3 classes in order to work with the message queue: Message
, Producer
, and Consumer
.
Producers and consumers exchange data using one or multiple queues that may be created using the Queue Class.
A queue is responsible for holding messages which are produced by producers and are delivered to consumers.
Creating a queue
const { Queue, EQueueType } = require('redis-smq');
const queue = new Queue();
// Creating a LIFO queue
queue.save('my_queue', EQueueType.LIFO_QUEUE, (err) => console.log(err));
Producing a message
const { Producer, Message } = require('redis-smq');
const producer = new Producer();
const message = new Message();
message.setQueue('my_queue').setBody('Hello Word!')
producer.produce(message, (err) => console.log(err));
Consuming a message
const { Consumer } = require('redis-smq');
const consumer = new Consumer();
const messageHandler = (message, cb) => {
console.log(message.getBody());
cb();
}
consumer.consume('my_queue', messageHandler, (err) => console.log(err));
Documentation
See RedisSMQ Docs for more details.
Contributing
So you are interested in contributing to this project? Please see CONTRIBUTING.md.