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

message-brokers

v1.8.1

Published

This package contains functions to publish the messages into the message brokers like rabbitmq.

Readme

message-brokers

npm version npm downloads node version

Message-Brokers is a package designed for managing RabbitMQ connections and operations. It simplifies the setup of queues and exchanges based on provided configurations and supports publishing messages to RabbitMQ with customizable routing keys and priorities. The package also integrates caching for better message management and retry mechanisms in case of failures.

Installation

Using npm

npm i message-brokers

Using yarn

yarn add message-brokers

Initialization

Set the following environment variables:

RABBITMQ_URL=amqp://admin:pwd@localhost:5672

(Optional)
ACTIVE_MESSAGE_BROKER=rabbitmq
REDIS_PORT=6260
CACHING_ENABLED=true
RABBITMQ_DEPLOYMENT_ENV=stage (if using same rabbitmq stack for multiple environments, exchanges/queues/routing-keys get appended with this value. e.g. if rabbitmq deployment env is stage, then exchanges/queues/routing-keys will be appended with .stage)
DATACLOAK_DISABLE=true (if you want to disable datacloak queue for stage/demo deployments)
// ES5 Syntax
const MessageBrokers = require("message-brokers");
// ES6 Syntax
import MessageBrokers from "message-brokers";

const messageBrokers = new MessageBrokers();

Initialization with MongoDB for deadqueue

1. Mongoose initialization

const MessageBrokers = require("message-brokers");
const mongoose = require("mongoose");

const mongoConnectionHolder = { connection: null };

mongoose.connect("mongodb://localhost:27017/db");

const db = mongoose.connection;

db.on("connected", () => {
  console.log("✅ Mongoose connected!");
  mongoConnectionHolder.connection = db;
});

db.on("error", (err) => {
  console.error("❌ Mongoose connection error:", err);
});

const messageBrokers = new MessageBrokers(mongoConnectionHolder, "app_name");

2. Native Mongodb driver initialization

const MessageBrokers = require("message-brokers");
const { MongoClient } = require("mongodb");

const mongoUrl = "mongodb://localhost:27017";
const dbName = "db";

const client = new MongoClient(mongoUrl, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

const mongoConnectionHolder = { connection: null };

client
  .connect()
  .then(() => {
    console.log("✅ MongoDB connected!");
    mongoConnectionHolder.connection = client.db(dbName);
  })
  .catch((error) => console.error("❌ MongoDB connection failed:", error));

const messageBrokers = new MessageBrokers(mongoConnectionHolder, "app_name");

Usage

// Publish har
messageBrokers.publishHar(har);

// Publish har_meta
messageBrokers.publishHarMeta(har_meta);

// Publish lab_api_response
messageBrokers.publishLabApiResponse(lab_api_response);

// Publish purchase_details
messageBrokers.publishPurchaseDetails(purchase_details);

// Publish lab_location_data
messageBrokers.publishLabLocationData(lab_location_data);

// Publish input_object
messageBrokers.publishInputObject(input_object);

// Publish har_stub
messageBrokers.publishHarStub(har_stub);

// Publish raw_queue
messageBrokers.publishRawQueue(raw_queue);

// Publish notification_messages_logs
messageBrokers.publishNotificationMessagesLogs(notification_messages_logs);

// Publish amqp_lab_api_response
messageBrokers.publishAmqpLabApiResponse(amqp_lab_api_response);