Registry / messaging / rabbit-queue

rabbit-queue

JSON →
library5.9.2jsnpmunverified

Rabbit-Queue is a TypeScript-based abstraction layer over amqplib for managing RabbitMQ queues, exchanges, and RPC patterns. Current version 5.9.2 (stable, 2023) provides easy queue creation, delayed publishing, topic binding, reply patterns, and reconnection handling. It requires Node >=10.0.0 and is designed for producer-consumer workflows with JSON serialization by default. Key differentiators include built-in reply patterns, scheduled publishing, and a BaseQueueHandler for retry logic with dead-letter queues.

npm install rabbit-queue
INSTALL
IMPORT
SIG · RABBIT-QUEUE
R
rabbit-queue
messagingjavascriptv5.9.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.

Rabbit
import { Rabbit } from 'rabbit-queue'
import Rabbit from 'rabbit-queue'
Rabbit is a named export (not default); CommonJS require() is also supported
BaseQueueHandler
import { BaseQueueHandler } from 'rabbit-queue'
const { BaseQueueHandler } = require('rabbit-queue')
Require is fine, but ensure you're using the correct symbol name; types are included
RabbitMQConfig
import { RabbitMQConfig } from 'rabbit-queue'
TypeScript-only; import type if using isolatedModules

Connects to RabbitMQ with prefetch, reply pattern, and reconnection handling, then creates a queue and publishes a message.

const { Rabbit } = require('rabbit-queue'); const rabbit = new Rabbit(process.env.RABBIT_URL || 'amqp://localhost', { prefetch: 5, replyPattern: true, scheduledPublish: false, prefix: '', }); rabbit.on('connected', () => { console.log('Connected to RabbitMQ'); rabbit.createQueue('tasks.queue', { durable: true }, (msg, ack) => { console.log('Processing:', msg.content.toString()); ack(null, 'done'); }).then(() => { console.log('Queue ready'); }); }); rabbit.on('disconnected', (err) => { console.error('Disconnected:', err.message); setTimeout(() => rabbit.reconnect(), 1000); }); rabbit.publish('tasks.queue', { task: 'hello' }, { correlationId: '1' });
Debug
Known issues
gotchaCreating a queue inside the 'connected' event is required for reliable reconnection, but the queue may be re-created on each reconnect (durable will survive).
fix
Always check queue existence or use 'assertQueue' via the raw channel if needed; createQueue is idempotent for same options.
affects: >=1.0.0
gotchapublishWithDelay creates a new queue per expiration value (prefix_delay_expiration), leading to potential queue explosion if many different delays are used.
fix
Use a limited set of fixed delay values or implement your own delay mechanism.
affects: >=5.0.0
gotchaThe Rabbit instance emits 'connected' on initial connection and reconnection; handlers attached once may fire multiple times. Ensure idempotent queue setup.
fix
Use a flag or remove old listeners before adding new ones.
affects: >=1.0.0
breakingVersion 5.0.0 dropped support for Node <10.0.0; RPC streams require Node >=10.0.0.
fix
Update Node to >=10.0.0 if using RPC streams.
affects: >=5.0.0
Errors
Common errors & fixes
TypeError: Rabbit is not a constructor
Default import used instead of named import.
fix
Use `const { Rabbit } = require('rabbit-queue');` or `import { Rabbit } from 'rabbit-queue';`
Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'myqueue'"
Queue already exists with different durability or options.
fix
Ensure queue arguments match existing queue or delete it.
TimeoutError: Timed out after 100ms
No reply received within the timeout for getReply or getTopicReply.
fix
Increase timeout, ensure consumer is running and replies correctly.
Upgrade
Version history
5.9.2latest on npm
Audit
Dependencies
amqplibrequiredCore AMQP 0-9-1 client used for all RabbitMQ communication
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
rabbit-queue — npm install rabbit-queue · libregistry