Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A simple high-performance Redis message queue for Node.js.

License

Notifications You must be signed in to change notification settings

weyoss/redis-smq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1,453 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RedisSMQ

Pre-release (next) Build (next) Code Quality (next)

πŸ’‘ Note: You are viewing the next branch with upcoming features. For stable releases, check the master branch.

A high-performance Redis message queue for Node.js β€” simple to use, built for scale.

✨ Features

🎯 Use Cases

  • Background jobs: emails, reports, data processing
  • Task scheduling with automatic retries
  • Microservices communication
  • Real-time event processing for gaming, IoT, analytics

πŸ“‹ Requirements

πŸš€ 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

⚠️ v9 Breaking Changes: If upgrading, read the v9.0.0 Release Notes.

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...');
  });
});

πŸ“¦ 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

🀝 Contributing

We welcome contributions! Please read CONTRIBUTING.md for guidelines.

πŸ“„ License

RedisSMQ is released under the MIT License.