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

Repository files navigation

Important Notice
Please be aware that RedisSMQ is currently undergoing significant development. Pre-release updates may introduce breaking changes at any time. The master branch always reflects the latest developments. For details on the most recent stable release, please refer to RedisSMQ v7.2.3.

RedisSMQ

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

Tests Code Quality Coverage Status NPM Version NPM Downloads

RedisSMQ

RedisSMQ (Redis Simple Message Queue) is a lightweight and efficient message queue system built on Redis. It is designed to streamline message brokering and task processing in distributed systems, leveraging Redis's fast in-memory capabilities to provide reliable and quick message queuing. This allows developers to implement various asynchronous processing patterns with ease.

Key Features

  • Simplicity: It focuses on being easy to set up and use, making it accessible for developers who need simple message queuing without the complexity of larger systems.

  • High Performance: By utilizing Redis, RedisSMQ offers high throughput and low latency, making it suitable for applications that require real-time processing.

  • Durability and Reliability: It includes mechanisms for ensuring message delivery and handling failures gracefully, which is critical in production environments.

  • Scalability: RedisSMQ is designed to scale horizontally, making it suitable for large-scale applications.

Use Cases

RedisSMQ: Multi-Queue Producers & Multi-Queue Consumers

  • Task Queuing: Managing background tasks, such as email sending or data processing.
  • Job Scheduling: Efficiently scheduling and retrying tasks.
  • Distributed Systems: Communication between multiple services in microservices architectures.
  • Real-Time Processing: Handling real-time events in gaming, IoT, or analytics systems.

Overall, RedisSMQ is a reliable, scalable, and easy-to-use message queue system that is well-suited for a wide range of applications, from real-time data processing to microservices architecture.

What's New?

🚀 RedisSMQ Version 8 Release Candidate (RC) is now available! Version 8 brings significant improvements and new features, including:

  • 🆕 Refactored and optimized codebase.
  • 🆕 Enhanced message storage and handling capabilities.
  • 🆕 Real-time message status tracking by ID.
  • 🆕 Introduction of Pub/Sub delivery models and consumer groups.
  • 🆕 Performance enhancements and sandboxing for message handlers using Message Handler Worker Threads.
  • 🆕 Cross-system event propagation via EventBus.
  • 🆕 Improved error handling to report critical errors without crashing the main process.
  • 🆕 Support for ESM modules.

Current Status of RedisSMQ Version 8 RC:

  • ✅ RedisSMQ Common Library
  • ✅ RedisSMQ Core Library
  • ✅ RESTful API
  • ⏳ Web UI (In Progress)

Explore the latest features and improvements by trying out RedisSMQ v8 RC, and feel free to report any bugs or issues. If you prefer a stable release with a fully functional HTTP API and Web UI, consider using RedisSMQ v7.

Installation

To install RedisSMQ, run:

npm install redis-smq@rc

Considerations

  • The minimum Node.js version required is >= 18 (RedisSMQ is tested with currently active LTS and maintenance LTS Node.js releases).
  • The minimum Redis server version required is 4.0.0.

Usage

How it Works

  1. Producer: An application sends a message to RedisSMQ, which stores the message in a Redis queue.
  2. Consumer: Another application or thread consumes the message from the Redis queue.
  3. Acknowledgement (Ack/Unack): The consumer sends back an acknowledgement (ACK) or unacknowledgement (UNACK) to let RedisSMQ know whether the message was processed successfully.

Creating a Queue

const queue = new Queue();
queue.save(
  'my_queue',
  EQueueType.LIFO_QUEUE,
  EQueueDeliveryModel.POINT_TO_POINT,
  (err) => {
    if (err) console.error(err);
  },
);

In this example, we define a LIFO queue with a POINT-TO-POINT delivery model.

Refer to Queues for more details.

Producing a Message

const msg = new ProducibleMessage();
msg.setQueue('my_queue').setBody('Hello World!');
producer.produce(msg, (err, ids) => {
  if (err) console.error(err);
  else console.log(`Produced message IDs: ${ids.join(', ')}`);
});

For further details, see Producing Messages.

Consuming a Message

const consumer = new Consumer();
const messageHandler = (msg, cb) => {
  console.log(msg.body);
  cb();
};
consumer.consume('my_queue', messageHandler, (err) => {
  if (err) console.error(err);
});

To learn more, visit Consuming Messages.

Documentation

For more information, visit the RedisSMQ Docs.

Contributing

Interested in contributing to this project? Please check out our CONTRIBUTING.md.

License

This project is licensed under the MIT License.