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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@outbox-event-bus/rabbitmq-publisher

v2.0.3

Published

![npm version](https://img.shields.io/npm/v/@outbox-event-bus/rabbitmq-publisher?style=flat-square&color=2563eb) ![license](https://img.shields.io/npm/l/@outbox-event-bus/rabbitmq-publisher?style=flat-square&color=2563eb)

Readme

RabbitMQ Publisher

npm version license

Enterprise-Grade Message Routing

RabbitMQ (AMQP) publisher for outbox-event-bus. Forwards events to RabbitMQ exchanges with intelligent routing and configurable retries.

import { RabbitMQPublisher } from '@outbox-event-bus/rabbitmq-publisher';

const publisher = new RabbitMQPublisher(bus, {
  channel: amqpChannel,
  exchange: 'events-exchange',
  routingKey: 'my-app.events' // Optional
});

publisher.subscribe(['user.created']);

When to Use

Choose RabbitMQ Publisher when:

  • You need complex routing (fanout, topic, direct).
  • You require message prioritization.
  • You want to use standard AMQP protocols.
  • You need to integrate with heterogeneous systems that support RabbitMQ.

Consider alternatives when:

  • You want a fully managed serverless service (use AWS SNS/EventBridge).
  • You need distributed log streaming (use Kafka).
  • You want the simplest possible setup (use Redis Streams).

Installation

npm install @outbox-event-bus/rabbitmq-publisher amqplib

Configuration

RabbitMQPublisherConfig

interface RabbitMQPublisherConfig {
  channel: Channel;               // amqplib Channel instance
  exchange: string;               // Target exchange name
  routingKey?: string;            // Optional static routing key
  processingConfig?: {
    bufferSize?: number;          // Default: 50
    bufferTimeoutMs?: number;     // Default: 100
    concurrency?: number;         // Default: 5
    maxBatchSize?: number;        // Optional downstream batch limit
  };
  retryConfig?: {
    maxAttempts?: number;         // Default: 3
    initialDelayMs?: number;      // Default: 1000
    maxDelayMs?: number;          // Default: 10000
  };
}

Batching & Buffering

This publisher has buffering enabled by default (50 items or 100ms). This safe default ensures efficient use of the AMQP channel while maintaining low latency.

To tune buffering, adjust the processingConfig:

const publisher = new RabbitMQPublisher(bus, {
  // ...
  processingConfig: {
    bufferSize: 100,
    bufferTimeoutMs: 50
  }
});

Usage

Basic Setup

import { RabbitMQPublisher } from '@outbox-event-bus/rabbitmq-publisher';

const publisher = new RabbitMQPublisher(bus, {
  channel: myChannel,
  exchange: 'app-events'
});

publisher.subscribe(['*']);

Dynamic Routing

If routingKey is not provided, the event type is used as the routing key automatically.

Configuration Options

  • channel: An instance of the amqplib Channel.
  • exchange: The exchange to publish to.
  • routingKey: (Optional) The routing key. Default: uses event.type.
  • processingConfig: (Optional) Settings for accumulation and batching.
    • bufferSize: Number of events to accumulate in memory before publishing. Default: 50.
    • bufferTimeoutMs: Maximum time to wait for a buffer to fill before flushing. Default: 100ms.
    • concurrency: Maximum number of concurrent processing tasks. Default: 5.
    • maxBatchSize: (Optional) If set, the accumulated buffer will be split into smaller downstream batches.
  • retryConfig: (Optional) Custom retry settings for publishing failures.
    • maxAttempts: Maximum number of publication attempts. Default: 3.
    • initialDelayMs: Initial backoff delay in milliseconds. Default: 1000ms.
    • maxDelayMs: Maximum backoff delay in milliseconds. Default: 10000ms.

[!NOTE] RabbitMQ publishers are often used with smaller buffers for lower latency, but larger buffers can significantly improve throughput for high-volume event streams.

Message Format

Messages are published as JSON buffers:

| AMQP Field | Value | Description | |------------|-------|-------------| | Body | JSON.stringify(event) | The full event object. | | Routing Key | config.routingKey or event.type | Used for routing to queues. | | Headers | eventType, eventId | Metadata headers. |

Error Handling

Application-Level Retries

The RabbitMQ publisher implements exponential backoff retries to handle channel buffer saturation or temporary connection drops.

const publisher = new RabbitMQPublisher(bus, {
  // ...
  retryConfig: {
    maxAttempts: 5,
    initialDelayMs: 500
  }
});

Troubleshooting

channel buffer full

  • Cause: Publishing faster than RabbitMQ can accept (backpressure).
  • Solution: Check your RabbitMQ server load and memory. The publisher will retry, but persistent failure indicates an infrastructure bottleneck.

Unrouteable Messages

  • Cause: Misconfigured exchange or routing keys.
  • Solution: Ensure the exchange exists and queues are bound with appropriate keys matching the event type.

License

MIT © Dunika