Registry / messaging / rascal-redis-counter

rascal-redis-counter

JSON →
library0.2.4jsnpmunverified

A Redis-backed redelivery counter for the Rascal AMQP library, allowing RabbitMQ consumers to track message redelivery counts in Redis rather than in-memory. Version 0.2.4 is the latest stable release. It is a small, focused utility that integrates solely with Rascal's redeliveries configuration. Unlike Rascal's built-in counters, this enables shared redelivery limits across multiple broker instances by using a centralized Redis store.

npm install rascal-redis-counter
INSTALL
IMPORT
SIG · RASCAL-REDIS-COUNT
R
rascal-redis-counter
messagingjavascriptv0.2.4
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.

rascalRedisCounter
const rascalRedisCounter = require('rascal-redis-counter');
import rascalRedisCounter from 'rascal-redis-counter';
Package does not provide ESM exports; use CommonJS require.
counters
const counters = { redisCounter: require('rascal-redis-counter') };
const counters = { redisCounter: 'rascal-redis-counter' };
The counter must be the module export, not a string.
config
const config = require('./config'); // JSON with redeliveries.counters.redisCounter
Configuration is done via Rascal's config file, not directly with this module.

Shows how to configure Rascal with the Redis counter and subscribe to a queue with redelivery tracking.

const Rascal = require('rascal'); const config = require('./config'); const redisCounter = require('rascal-redis-counter'); const counters = { redisCounter: redisCounter }; Rascal.Broker.create( Rascal.withDefaultConfig(config), { counters: counters }, function(err, broker) { if (err) throw err; broker.on('error', (err) => console.error(err.message)); broker.subscribe('work_sub', (err, subscription) => { if (err) throw err; subscription.on('message', (msg, ackOrNack) => { console.log('Received:', msg); ackOrNack(); }); }); } );
Debug
Known issues
gotchaThe counter key in the config must exactly match the key used in the counters object passed to Broker.create.
fix
Ensure the name in redeliveries.counters (e.g., 'redisCounter') is passed as the same key in the counters object.
affects: >=0.0.0
gotchaRascal redeliveries limit is applied per broker instance; using a shared Redis counter across instances ensures the limit is global.
fix
Use the shared counter in all broker instances to avoid per-instance redelivery limits.
affects: >=0.0.0
deprecatedThe 'redis' package used internally is the legacy node_redis; consider switching to 'ioredis' if you need modern Redis features.
fix
Use 'redis' v3+ or migrate to a newer package that uses 'ioredis'.
affects: >=0.0.0
breakingMinor version bumps may change the internal counter key format, potentially losing redelivery state.
fix
Pin to a specific minor version and test after upgrades.
affects: >=0.1.0
gotchaThe Redis client connection options are passed directly from the Rascal config; no validation or defaults are applied.
fix
Ensure the 'client' object in config has valid Redis options (e.g., host, port, db).
affects: >=0.0.0
Errors
Common errors & fixes
Error: Invalid counter type: undefined. Expected one of: redisCounter
The config's redeliveries.counters type does not match the counter key used in the counters object.
fix
Set type to 'redisCounter' in the config and pass the counter as { redisCounter: ... }.
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server is not running or unreachable.
fix
Start Redis server or adjust the client config to point to a running instance.
TypeError: counter.increment is not a function
The value passed as the counter is not the module export, but something else (e.g., a string).
fix
Use require('rascal-redis-counter') directly, not its property or path.
Rascal: Redeliveries limit exceeded for message ...
The message has been redelivered more times than the configured limit.
fix
Increase the redeliveries limit in the subscription config or handle the message in dead letter.
Warning: Redis counter key not found for message, using default count
The counter key (usually message ID) is missing in Redis; this may happen after a Redis flush or restart.
fix
Ensure Redis persistence is configured; or accept that counters reset after Redis restart.
Upgrade
Version history
0.2.4latest on npm
Audit
Dependencies
rascalrequiredProvides the redelivery counter interface that this plugin implements
redisrequiredUnderlying Redis client for managing counter state
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
rascal-redis-counter — npm install rascal-redis-counter · libregistry