npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@relab/nestjs-rabbit-mq

v6.0.0

Published

RabbitMQ helpers for Nest.js

Readme

@relab/nestjs-rabbit-mq

Purpose

This package provides helpers for integrating RabbitMQ with NestJS microservices. It simplifies queue setup, message acknowledgement, error handling, and dead-letter/reprocessing logic, so you can focus on your business logic.

Key Features

  • Automatic queue setup: Ensures main, reprocess, and dead-letter queues are created with correct options.
  • Message acknowledgement: Automatically acknowledges messages on success, nacks on error, and moves messages to DLQ after max attempts.
  • Re-processing logic: Failed messages are retried via a reprocess queue before being sent to a dead-letter queue.
  • Configurable retry and queue options.

Installation

pnpm add @relab/nestjs-rabbit-mq

Usage

Consumer

main.ts

import { configureRabbitMqMicroservice } from '@relab/nestjs-rabbit-mq'

const app = /* create nestjs app */

await configureRabbitMqMicroservice(app, {
    connectionString: '<connection string>',
    maxAttempts: 3,
    queue: {
        name: '<queue_name>',
        durable: true,
        reprocessTimeout: 30_000,      // optional, ms
        deadLetterTimeout: 48 * 60 * 60 * 1000, // optional, ms
        forceCreate: false,            // optional
    },
})

Producer

module.ts

import { configureRabbitMqMicroservice } from '@relab/nestjs-rabbit-mq'

@Module({
    providers: [
        {
            provide: 'SMS_SERVICE',
            useFactory: (traceContextService: TraceContextService) => {
                return RabbitMqClientProxyFactory.create({
                  connectionString: 'amqp://user:password@localhost:5672'
                  queueName: 'queue1',
                  traceContextService
                })
            },
        },
    ],
    exports: [],
})
export class Module {}

API

configureRabbitMqMicroservice(app, options)

Configures your NestJS app to use RabbitMQ as a microservice transport, sets up the required queues, and installs global message acknowledgement logic.

Parameters

  • app: INestApplication — Your NestJS application instance.
  • options: object
    • connectionString (string, required): RabbitMQ connection string.
    • maxAttempts (number, optional, default: 3): Max delivery attempts before moving message to DLQ.
    • queue (object, required):
      • name (string, required): Name of the main queue.
      • durable (boolean, optional): Whether the queue survives broker restarts.
      • reprocessTimeout (number, optional, default: 30000): Time (ms) before a message in the reprocess queue is retried.
      • deadLetterTimeout (number, optional, default: 48h): Time (ms) before a message in the DLQ is discarded.
      • forceCreate (boolean, optional): If true, deletes and recreates queues if their options do not match.

How it works

  • Queue Setup: Three queues are created per logical queue:
    • <queue_name>: Main queue.
    • <queue_name>_rlq: Reprocess letter queue (for retrying failed messages).
    • <queue_name>_dlq: Dead letter queue (for messages that exceeded max attempts).
  • Message Flow:
    1. On handler success, message is acknowledged.
    2. On handler error, message is nacked. If delivery attempts exceed maxAttempts, it is moved to the DLQ.
    3. Messages in the reprocess queue are retried after reprocessTimeout.
    4. Messages in the DLQ are retained for deadLetterTimeout.

Advanced

You can also use the following exports for custom setups:

  • RabbitMQAckInterceptor: The interceptor responsible for ack/nack logic.
  • setupQueue(connectionString, queueName, options): Manually set up queues.

License

MIT