Registry / messaging / rsmq-worker

rsmq-worker

JSON →
library0.5.2jsnpmunverified

RSMQ Worker (v0.5.2) is a helper library for building workers on top of Redis Simple Message Queue (RSMQ). It provides event-driven message processing with configurable polling intervals, retry delays, and timeout handling. Last updated in 2016, it has few releases and is in maintenance mode. Key differentiators: simple API, event-based (message/error/timeout/exceeded), and built-in exponential backoff. It requires RSMQ 3+ and a Redis server 2.6+.

npm install rsmq-worker
INSTALL
IMPORT
SIG · RSMQ-WORKER
R
rsmq-worker
messagingjavascriptv0.5.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RSMQWorker
const RSMQWorker = require('rsmq-worker');
import RSMQWorker from 'rsmq-worker';
CommonJS only; no ESM or named exports.
new RSMQWorker(queuename, options)
const worker = new RSMQWorker('myqueue', { autostart: true });
const worker = RSMQWorker('myqueue');
Must use 'new' keyword.
worker.on('message', handler)
worker.on('message', (msg, next, id) => { next(); });
worker.on('message', (msg) => { console.log(msg); });
Must call next() to acknowledge and delete the message.

Creates an RSMQWorker with a custom Redis host/port, sets processing timeout, and attaches event listeners for message, error, exceeded, and timeout.

const RSMQWorker = require('rsmq-worker'); const worker = new RSMQWorker('myqueue', { interval: [0, 1, 5, 10], maxReceiveCount: 3, invisibletime: 30, defaultDelay: 1, autostart: true, timeout: 5000, host: process.env.REDIS_HOST || '127.0.0.1', port: process.env.REDIS_PORT || 6379 }); worker.on('message', (msg, next, id) => { console.log(`Received message ID ${id}: ${msg}`); next(); }); worker.on('error', (err, msg) => { console.error('Error processing message', msg.id, err); }); worker.on('exceeded', (msg) => { console.warn('Message exceeded max receive count', msg.id); }); worker.on('timeout', (msg) => { console.warn('Message processing timed out', msg.id, 'receive count:', msg.rc); });
Debug
Known issues
breakingRSMQ Worker requires RSMQ 3.x and Redis 2.6+ due to LUA scripting. Using older versions causes errors.
fix
Update RSMQ to >=3.0.0 and Redis to >=2.6.
affects: >=0.5.0
deprecatedThe package has not been updated since 2016 and is considered stable but unmaintained.
fix
Consider migrating to alternatives like Bull or Bee-Queue for newer Redis features.
affects: >=0.0.1
gotchaIf you do not call next() in the message handler, the worker's processing will hang and messages will become invisible until the invisibletime expires.
fix
Always call next() after processing, even on error, to allow the message to be either deleted or retried.
affects: >=0.0.1
gotchaThe timeout option is in milliseconds, but the default is 3000ms (3 seconds). If set to 0, the worker waits indefinitely, which can cause message stalls.
fix
Set a reasonable timeout (e.g., 5000) or handle the 'timeout' event to catch and process stalled messages.
affects: >=0.0.1
gotchaThe interval option is an array of seconds used for exponential backoff between polls. The first poll is immediate, then 1s, 5s, 10s, etc. Setting a single-element array disables backoff.
fix
Provide an array with multiple values or use the default [0,1,5,10] for standard backoff behavior.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: RSMQWorker is not a constructor
Calling RSMQWorker without 'new' or using incorrect import (ESM vs CJS).
fix
Use const worker = new RSMQWorker('queue', options); and ensure you require('rsmq-worker') correctly.
Error: MOVED 1234 127.0.0.1:6380
Redis cluster mode is not supported; the worker expects a single Redis instance.
fix
Connect to a single Redis instance or use a library that supports cluster (e.g., ioredis with custom rsmq instance).
Error: NOAUTH Authentication required.
No password provided to Redis when Redis requires authentication.
fix
Pass a redis client with auth: const redis = require('redis').createClient({password: 'secret'}); then pass to options.redis.
Error: OOM command not allowed when used memory > 'maxmemory'.
Redis ran out of memory; the message queue may be full.
fix
Increase Redis maxmemory or reduce queue size by shortening message retention.
Upgrade
Version history
0.5.2latest on npm
Audit
Dependencies
rsmqrequiredCore message queue library; RSMQWorker wraps its API.
redisoptionalRedis client used if no RSMQ or redis instance is provided.
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
rsmq-worker — npm install rsmq-worker · libregistry