README.md
April 20, 2026 ยท View on GitHub
๐ก Note: You are viewing the
nextbranch with upcoming features. For stable releases, check themasterbranch.
โจ Features
- ๐ฌ Reliable delivery with retries
- ๐ Multiple queue types: FIFO, LIFO, Priority
- ๐ Flexible routing: Direct/Topic/Fanout exchanges + Direct queue publishing
- ๐ฅ Pub/Sub & Point-to-Point delivery models with native consumer groups
- ๐ฆ Queue-level rate limiting
- โฐ Built-in scheduler: delays, CRON, repeating
- ๐ Queue state management: pause/stop/resume + audit
- โฑ๏ธ Message TTL & consumption timeouts
- ๐ High-throughput design with atomic Lua scripts
- ๐ฆ Batch acks & Batch unacks โ 99% fewer Redis calls
- ๐งต Worker threads for CPU-heavy handlers
- ๐ Multi-queue producers & consumers with multiplexing support
- ๐ก Event bus for real-time internal events
- ๐ REST API with OpenAPI + Swagger
- ๐ Web UI for live management
- ๐ฏ Process-wide API โ initialize once, factory methods, single shutdown
- ๐ Dual callback & promise support
- ๐ฆ ESM + CJS module support
- ๐ TypeScript-first with rich docs
๐ฏ Use Cases
- Background jobs: emails, reports, data processing
- Task scheduling with automatic retries
- Microservices communication
- Real-time event processing for gaming, IoT, analytics
๐ Requirements
- Node.js 20+
- Redis 4+
- Choose one Redis client:
ioredisor@redis/client
๐ Quick Start
1. Install
# Core packages
npm install redis-smq@next redis-smq-common@next --save
# Pick a Redis client
npm install ioredis --save
# OR
npm install @redis/client --save
2. Initialize (once per process)
import { RedisSMQ } from 'redis-smq';
import { ERedisConfigClient } from 'redis-smq-common';
// Simple initialization
RedisSMQ.initialize(
{
client: ERedisConfigClient.IOREDIS,
options: { host: '127.0.0.1', port: 6379 }
},
(err) => {
if (err) console.error('RedisSMQ init failed:', err);
}
);
3. Create a Queue
import { RedisSMQ, EQueueType, EQueueDeliveryModel } from 'redis-smq';
const queueManager = RedisSMQ.createQueueManager();
queueManager.save(
'my_queue',
EQueueType.LIFO_QUEUE,
EQueueDeliveryModel.POINT_TO_POINT,
(err) => {
if (err) console.error('Queue creation failed:', err);
else console.log('โ
Queue created');
}
);
4. Produce a Message
import { RedisSMQ, ProducibleMessage } from 'redis-smq';
const producer = RedisSMQ.createProducer();
producer.run((err) => {
if (err) return console.error('Producer failed:', err);
const msg = new ProducibleMessage()
.setQueue('my_queue')
.setBody('Hello World!');
producer.produce(msg, (err, ids) => {
if (err) console.error('Send failed:', err);
else console.log(`๐จ Sent message: ${ids.join(', ')}`);
});
});
5. Consume Messages
import { RedisSMQ } from 'redis-smq';
const consumer = RedisSMQ.createConsumer();
consumer.run((err) => {
if (err) return console.error('Consumer failed:', err);
const handler = (message, done) => {
console.log('๐ฅ Received:', message.body);
done(); // Acknowledge
};
consumer.consume('my_queue', handler, (err) => {
if (err) console.error('Consume failed:', err);
else console.log('๐ Listening on my_queue...');
});
});
๐งฉ Using Promises
import { RedisSMQ, EQueueType, EQueueDeliveryModel } from 'redis-smq';
try {
// Initialize RedisSMQ
await RedisSMQ.initialize({
client: ERedisConfigClient.IOREDIS,
options: { host: 'localhost', port: 6379 }
});
// Create a Queue
const queueManager = RedisSMQ.createQueueManager();
await queueManager.save(
'my_queue',
EQueueType.LIFO_QUEUE,
EQueueDeliveryModel.POINT_TO_POINT,
);
// Create and start a producer
const producer = RedisSMQ.createProducer();
await producer.run();
// Send a message
const message = new ProducibleMessage()
.setQueue('my-queue')
.setBody({ hello: 'world' });
const messageIds = await producer.produce(message);
console.log('Message published:', messageIds);
// Create and start a consumer
const consumer = RedisSMQ.createConsumer();
await consumer.run();
// Consume messages
await consumer.consume('my-queue', async (message) => {
console.log('Received:', message.getBody());
// Successful acknowledgement
});
} catch (err) {
console.error('Error:', err);
}
See Dual Callback & Promise Support.
๐ฆ Packages
| Package | Description |
|---|---|
| redis-smq | Core message queue library |
| redis-smq-common | Shared utilities |
| redis-smq-rest-api | REST API with Swagger UI |
| redis-smq-web-ui | Web dashboard |
| redis-smq-web-server | Web server for UI & API |
| redis-smq-benchmarks | Performance testing |
๐ Version Compatibility: Always use matching versions. See version compatibility guide.
๐ Documentation
- Full Documentation - Complete API reference and guides
- REST API - API endpoints and usage
- Web UI - Dashboard setup and features
๐ค Contributing
We welcome contributions! Please read CONTRIBUTING.md for guidelines.
๐ License
RedisSMQ is released under the MIT License.
