Skip to content

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

License

Notifications You must be signed in to change notification settings

lvshiling/redis-smq

 
 

Repository files navigation

Important

Currently, RedisSMQ is going under heavy development. Pre-releases at any time may introduce new commits with breaking changes. The master branch always reflects the most recent changes. To view the latest release reference see RedisSMQ v7.2.3

RedisSMQ

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

RedisSMQ

Tests Code quality Coverage Status NPM version NPM downloads

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

RedisSMQ Use Case: Multi-Queue Producers & Multi-Queue Consumers

RedisSMQ Multi-Queue Producers & Multi-Queue Consumers

What's new?

🚀 RedisSMQ v8 is coming soon!

Installation

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: ProducibleMessage, 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, ProducibleMessage } = require('redis-smq');

const producer = new Producer();

const msg = new ProducibleMessage();
msg.setQueue('my_queue').setBody('Hello Word!')

producer.produce(msg, (err) => console.log(err));

Consuming a message

const { Consumer } = require('redis-smq');

const consumer = new Consumer();
const messageHandler = (msg, cb) => {
  console.log(msg.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.

License

MIT

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.8%
  • Lua 5.4%
  • Other 0.8%