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

@musasutisna/nodco-rabbitmq

v1.1.0

Published

make easier configuration nodejs configuration intergration with rabbitmq

Downloads

81

Readme

Nodejs config api is package to make easier configuration nodejs configuration intergration with rabbitmq.

Getting started

Lets install nodco-rabbitmq with npm

npm install --save @musasutisna/nodco-rabbitmq

How to initialize

const nodcoRabbitmqConfig = require('@musasutisna/nodco-rabbitmq');

nodcoRabbitmqConfig(
  {
    host, // string, rabbitmq host
    port, // number, rabitmq port
    username, // string, rabbitmq user username
    password, // string, rabbitmq user password
    vhost, // string, rabbitmq virtual host
    queues, // array, list of queue will be declared
      [
        {
          name, // string, name of queue
          options // object, amqplib option for queue
        }
      ]
    exchanges // array, list of exchange list will be declared
      [
        {
          name, // string, name of exchange
          type, // string, typeof exchange
          options // object, amqplib option for exchange
        }
      ]
  }
)

| Method | Type | Description | |:--|:--|:--| | client | object | A list of RabbitMQ clients that are currently connected. | | channel| object | A list of RabbitMQ channels that are currently open. | | connect| async | Opens a connection to RabbitMQ. | | retries| async | Limits message retries using DLX (Dead Letter Exchange) properties. | | close | async | Closes all connections that have been established. |

connect Function

The connect function is an asynchronous function that establishes a connection to RabbitMQ. It ensures that the application is connected to the RabbitMQ server, allowing for communication and message processing.

Syntax

connect(key, cb);

Parameters

| Parameter | Type | Default | Description | |:--|:--|:--|:--| | key | object | N/A | The unique key in the configuration used during initialization to identify the connection configuration. | | cb | object | N/A | A callback function that is executed once the connection to RabbitMQ is successfully established. It receives the error (if any) and the connection object as parameters. |

Example

const configKey = 'myRabbitMQConfig';

connect(configKey, () => {
  console.log('Connected successfully.');
  // Further logic after successful connection can be added here.
});

Use Case

Establishing a connection to RabbitMQ: Use this function when you need to open a connection to the RabbitMQ server and perform operations like message publishing, subscribing to queues, or managing exchanges. The function ensures that the connection is properly initialized using the provided configuration.

retries Function

The retries function is an asynchronous function designed to handle message retry logic with a specified limit and optional republishing to another exchange if the limit is reached.

Syntax

retries(channel, msg, limit = 10, republish = null)

Parameters

| Parameter | Type | Default | Description | |:--|:--|:--|:--| | channel | object | N/A | An open RabbitMQ channel instance used to interact with the broker (e.g., for acknowledging or republishing messages). | | msg | object | N/A | The message object received from RabbitMQ, containing the message body, headers, and delivery metadata. | | limit | number | 10 | The maximum number of retry attempts allowed before acknowledging or republishing the message. | | republish | object | null | Optional. Specifies the configuration for republishing messages to another exchange. |

republish Object

If provided, the republish parameter should be an object with the following properties:

| Property | Type | Description | |:--|:--|:--| | exchange | string | The name of the target exchange to which the message will be republished. | | key | string | The routing key used to republish the message to the target exchange. |

Example

await retries(
  channel, 
  msg, 
  5, 
  { exchange: 'backup-exchange', key: 'retry-key' }
);

In this example:

  • The message will be retried up to 5 times.
  • If the retry limit is reached, the message will be republished to the backup-exchange using the routing key retry-key.
  • If no limit is provided, the function will default to 10 retries. If republish is not specified, it will default to null.

Use Case

The retries function is ideal for scenarios where you need to limit the number of processing attempts for a message and handle messages that cannot be successfully processed by either:

  • Acknowledging them after reaching the retry limit.
  • Republishing them to a dead-letter exchange or a fallback mechanism for further investigation.