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

rabbitmq-extension

v0.2.1

Published

rabbitmq

Downloads

244

Readme

rabbitmq-extension

A lightweight, strongly typed RabbitMQ client for Node.js and TypeScript built on top of amqplib.

Unlike many RabbitMQ frameworks, this library intentionally focuses only on transport responsibilities:

  • Sending messages
  • Consuming messages
  • Header mapping
  • Health checking
  • Type-safe APIs

It does not implement:

  • Retry policies
  • Dead Letter Queue (DLQ)
  • Validation
  • Business processing
  • Retry scheduling

Those concerns belong to a higher-level Message Processing library.

Examples:


Why Another RabbitMQ Library?

amqplib is an excellent low-level RabbitMQ client, but application code usually contains repetitive boilerplate:

  • Buffer conversion
  • JSON serialization
  • Header mapping
  • Generic types
  • Health checks

This library removes that boilerplate while staying close to RabbitMQ.

Instead of becoming another messaging framework, it provides a thin, reusable abstraction over amqplib.


Features

  • Strongly typed producer
  • Strongly typed consumer
  • Automatic header mapping
  • JSON support
  • Plain text support
  • Health checker
  • Connection timeout
  • Minimal abstraction
  • Built on top of amqplib

Installation

npm install rabbitmq-extension

or

npm install rabbitmq-extension amqplib

Design Philosophy

The goal is to keep the transport layer simple.

 Application

      ↓

RabbitMQ Library

      ↓

   amqplib

      ↓

RabbitMQ Server

The RabbitMQ library should only know about RabbitMQ.

Business concerns belong elsewhere.


Sender

Sending a message is straightforward.

const sender = new Sender<Order>(channel, "orders");

await sender.send(order);

Messages are automatically serialized before being published.


Consumer

Consumers receive typed objects.

const consumer = new Consumer<Order>(channel, "orders");

consumer.consume(async (order) => {
    console.log(order.id);
});

The library handles:

  • reading the message
  • JSON deserialization
  • header conversion
  • acknowledgement

Application code only processes the message.


JSON Messages

Enable JSON mode:

new Consumer<Order>(channel queue)
 RabbitMQ

    ↓

JSON String

    ↓

   Order

Plain Text Messages

JSON parsing can be disabled.

new Consumer<string>(channel, queue)
RabbitMQ

    ↓

 String

    ↓

Application

Message Headers

RabbitMQ headers are automatically converted into a simple string map.

Instead of handling different RabbitMQ header types,

MessagePropertyHeaders

applications receive

interface StringMap {
    [key: string]: string
}

Example:

sender.send(order, {
    correlationId: "12345",
    tenant: "company-a"
});

Consumer:

consumer.consume(async (order, headers) => {
    console.log(headers?.tenant);
});

Health Check

The library includes a lightweight RabbitMQ health checker.

const checker = new RabbitMQChecker(url);

await checker.check();

The checker attempts to establish a RabbitMQ connection within a configurable timeout.

Typical usage:

 Application

      ↓

   /health

      ↓

RabbitMQChecker

      ↓

  RabbitMQ

This integrates easily with Kubernetes readiness and liveness probes.


Connection Timeout

Connection attempts should never wait indefinitely.

The health checker supports configurable connection timeouts.

new RabbitMQChecker(url, 5000);

If RabbitMQ cannot be reached within the timeout, the connection fails immediately.


Logging

Optional logging callbacks are supported.

const consumer = new Consumer(channel, queue, logError, logInfo);

No logging framework is required.

Applications are free to integrate:

  • Winston
  • Pino
  • Bunyan
  • Custom loggers

Transport Responsibilities

This library intentionally focuses on RabbitMQ transport.

It provides:

  • Connection
  • Producer
  • Consumer
  • Serialization
  • Header conversion
  • Health checking

It intentionally does not provide:

  • Retry policies
  • Retry queues
  • Validation
  • Dead Letter Queue
  • Business workflow

These responsibilities belong to the Message Processing library.


Architecture

Business Application

        │

        ▼

Message Processing

--------------------------

   Validation
      Retry
Dead Letter Queue
   Retry Count
     Logging

         │

         ▼

      RabbitMQ

--------------------------

     Sender
    Consumer
     Headers
  Health Check

        │

        ▼

     amqplib

        │

        ▼

  RabbitMQ Server

This separation keeps the RabbitMQ library small, reusable, and focused on transport concerns.


Why Separate Transport from Processing?

Retry logic is not specific to RabbitMQ.

For example, the same business workflow can be implemented using:

  • RabbitMQ
  • Kafka
  • Amazon SQS
  • Azure Service Bus
  • Google Pub/Sub

By keeping transport and processing separate, business logic remains independent of the messaging technology.


Ecosystem

This library works naturally with the Message Processing library.

 RabbitMQ Server

        ↓

    amqplib

        ↓

rabbitmq-extension library

        ↓

Message Processing

        ↓

Business Services

The RabbitMQ library handles transport.

The Message Processing library handles:

  • Validation
  • Retry
  • Retry queues
  • Dead Letter Queue
  • Error handling
  • Logging

Together they provide a complete messaging solution while maintaining clear separation of responsibilities.


Design Goals

  • Thin abstraction over amqplib
  • Strong TypeScript typing
  • Minimal API surface
  • Transport-only responsibilities
  • Easy integration with higher-level processing libraries
  • No framework lock-in

License

MIT