A production-ready TypeScript RabbitMQ library (v1.0.27) that enforces industry best practice separation of concerns (Publisher→Exchanges, Consumer→Queues) with built-in automatic exponential backoff retry and dead letter queue routing after max retries. Features lazy loading (automatic connection on first use), auto-reconnection, support for direct/topic/fanout/headers exchanges, and full TypeScript types. Released on npm with a monthly cadence. Differentiators: explicit retry config per queue, event emitter interface, and no direct publisher-to-queue API (prevents anti-patterns). Requires Node >=16 and a running RabbitMQ instance.
npm install rabbitmq-with-retry-and-dlqNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates initialization, exchange assertion, queue setup with retry config, consuming, and publishing a message.
Call await initializeRabbitMQ(url) at application startup. Do not call it multiple times.
Use publisher.assertExchange() and publisher.publishToExchange() instead of direct queue publishing.
Use consumer.cancelConsumer(queueName) to stop consuming, or use the EventEmitter pattern.
Only call initializeRabbitMQ once. Use environment variables for dynamic config.
Upgrade Node.js to version 16 or higher.
Ensure await initializeRabbitMQ(url) is called first in your application startup.
Start RabbitMQ (e.g., docker run -d --name rabbitmq -p 5672:5672 rabbitmq:3) or provide correct URL via RABBITMQ_URL env var.
Use import { consumer } from 'rabbitmq-with-retry-and-dlq' (lowercase).Delete the existing queue or use consistent queue setup arguments across restarts.