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

@orbit-stream/message-queue

v1.0.4

Published

message-queue is a flexible and lightweight Node.js package that provides a unified interface for working with multiple message queue providers. Currently, it supports both RabbitMQ and Amazon SQS, allowing developers to easily publish, consume, acknowled

Readme

@orbit-stream/message-queue

Production-ready RabbitMQ client for Node.js applications with:

  • Auto reconnect
  • Heartbeat monitoring
  • Persistent publishing
  • Offline buffering
  • Queue restoration
  • Consumer recovery
  • Batch publishing
  • Message TTL support

Installation

npm install @orbit-stream/message-queue

Features

  • RabbitMQ connection management
  • Automatic reconnect handling
  • Durable queues
  • Persistent messages
  • Message TTL support
  • Offline queue buffering
  • Queue restoration after reconnect
  • Consumer auto recovery
  • Batch publishing support
  • Exponential reconnect backoff
  • Heartbeat monitoring
  • EventEmitter-based architecture

Quick Start

Producer + Consumer

const { createClient } = require("@orbit-stream/message-queue");

(async () => {
  const client = await createClient({
    type: "rabbitmq",

    url: "amqp://localhost",
  });

  client.on("connected", () => {
    console.log("Connected");
  });

  client.on("reconnecting", (delay) => {
    console.log(`Reconnecting in ${delay}ms`);
  });

  client.on("error", (err) => {
    console.error(err);
  });

  await client.subscribe("test-queue", async (message) => {
    console.log("Received:", message);
  });

  await client.publish("test-queue", {
    hello: "world",
  });
})();

Configuration

const client = await createClient({
  type: "rabbitmq",

  url: "amqp://localhost",
});

Default Configuration

These values are automatically applied internally:

{
  heartbeat: 30,

  prefetch: 100,

  reconnect: {
    retries: Infinity,
    minDelay: 1000,
    maxDelay: 30000,
    factor: 2,
  },

  buffer: {
    maxSize: 100000,
  },

  persistence: {
    enabled: false,
  },
}

Override Defaults

const client = await createClient({
  type: "rabbitmq",

  url: "amqp://localhost",

  heartbeat: 10,

  prefetch: 500,
});

Publish Message

await client.publish("telemetry", {
  temperature: 24,
});

Message TTL

Automatically delete messages after a duration.

Store for 1 minute only

await client.publish("telemetry", data, {
  ttl: 60000,
});

If message is not consumed within 60 seconds:

  • RabbitMQ automatically removes it

Durable Messages

Messages are automatically published with:

persistent: true;

Queues are automatically created with:

durable: true;

This means messages survive:

  • RabbitMQ restart
  • AmazonMQ maintenance
  • Consumer disconnects
  • Reconnects

Subscribe to Queue

await client.subscribe("telemetry", async (message) => {
  console.log(message);
});

Acknowledgements

Messages are only removed after successful processing.

Receive message
    ↓
Process message
    ↓
ACK sent
    ↓
Message removed

If consumer crashes before ACK:

  • RabbitMQ requeues message

Batch Manager

const { BatchManager } = require("@orbit-stream/message-queue");

const batch = new BatchManager(100, 5000, async (messages) => {
  console.log(messages.length);
});

batch.add({
  value: 1,
});

Parameters

| Parameter | Description | | --------- | -------------------- | | size | Max batch size | | interval | Flush interval in ms | | handler | Batch processor |


Auto Reconnect

The client automatically reconnects when:

  • RabbitMQ restarts
  • AmazonMQ maintenance occurs
  • Network interruptions happen
  • DNS temporarily fails
  • Heartbeat timeout occurs

Heartbeat Monitoring

Heartbeat monitoring is enabled by default:

heartbeat: 30;

This detects dead TCP connections automatically.

Especially important for:

  • AmazonMQ
  • Kubernetes
  • Docker
  • Cloud environments

Event Listeners

Connected

client.on("connected", () => {
  console.log("Connected");
});

Reconnecting

client.on("reconnecting", (delay) => {
  console.log(delay);
});

Error

client.on("error", (err) => {
  console.error(err);
});

Warning

client.on("warning", (msg) => {
  console.warn(msg);
});

Close Connection

await client.close();

Production Recommendations

Use heartbeat

heartbeat: 30;

Use durable queues

Enabled automatically.


Use persistent messages

Enabled automatically.


Handle errors

client.on("error", console.error);

Use TTL for realtime telemetry

ttl: 60000;

Example Architecture

Telemetry Producer
        ↓
RabbitMQ
        ↓
@orbit-stream/message-queue
        ↓
Consumer Services

Roadmap

Planned future adapters:

  • Amazon SQS
  • ActiveMQ
  • BullMQ

License

MIT