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

@artie-owlet/cabbit

v1.0.0

Published

Package for easy consuming messages from RabbitMQ

Readme

cabbit

CI Coverage Lint

Package for easy consuming messages from RabbitMQ.


Install

npm install @artie-owlet/cabbit

Usage

Get started

You can create cabbit with its own connection:

import { Cabbit } from '@artie-owlet/cabbit';
// using connection URL
const cabbit1 = new Cabbit('amqp://user:[email protected]:5672/');
// using options
const cabbit2 = new Cabbit({
    hostname: 'example.com',
    port: 5672,
    username: 'user',
    password: 'pwd',
    vhost: '/',
})

Or you can create your own connection (using the ConnectionWrapper) and pass it to Cabbit constructor (e.g. you also want to publish messages):

import { ConnectionWrapper } from '@artie-owlet/amqplib-wrapper';
import { Cabbit } from '@artie-owlet/cabbit';

const connWrap = new ConnectionWrapper('amqp://user:[email protected]:5672/?reconnectTimeout=1000');
// cabbit for consuming messages
const cabbit = new Cabbit(connWrap);
// another channel for publishing messages
const chan = await chanWrap.getChannel();

Consuming from named queue

graph LR
    pub{{Pub}} --> queue[test_queue] --> sub{{Sub}}
cabbit.queue('test_queue', (msg) => {
    if (msg.body === undefined) {
        console.error(msg.parseError);
    } else {
        console.log(msg.body);
    }
    msg.ack();
});

NOTE: Cabbit trying to decode and parse messages according to their encoding and MIME-type. If an error occurs the body will be undefined. Usually you should check it.

Simple subcribing to exchange

graph LR
    pub{{Pub}} --> ex((D test_ex)) -- key --> queue[test_queue] --> sub{{Sub}}

In such simple cases, Cabbit represents the subscription as a consumption from the exchange through the (named) queue:

cabbit.direct('test_ex').consume('test_queue', (msg) => {
    // handle message
    msg.ack();
}, 'key');

Temporary queue

Temporary queue - is a server-named queue which should be removed after the client disconnects. By default Cabbit consumes from a temporary queue with noAck=true.

graph LR
    pub{{Pub}} --> ex((D test_ex)) -- key --> queue[amq.gen-...] --> sub{{Sub}}
cabbit.direct('test_ex').consume((msg) => {
    // handle message
    // DON'T call msg.ack()
}, 'key');

Complex example

graph LR
    pub{{Pub}}
    sub{{Sub}}
    ex1((D log_ex))
    ex2((H error_ex))
    queue1[all_logs_q]
    queue2[test_err_q]
    pub --> ex1
    ex1 -- info --> queue1
    ex1 -- warn --> queue1
    ex1 -- error --> queue1
    queue1 --> sub
    ex1 -- error --> ex2 -->queue2 -->sub
const logEx = cabbit.direct('log_ex');

logEx.consume('all_logs_q', (msg) => {
    switch (msg.fields.routingKey) {
        // handle message according to its routing key
    }
    msg.ack();
}, ['info', 'warn', 'error']); // you can pass a list of routing keys

logEx.headers('error_ex').consume('test_err_q', (msg) => {
    // handle message
    msg.ack();
}, {
    'x-match': 'all',
    app: 'test',
});

Subscribing to multiple exchanges

graph LR
    pub1{{Pub 1}} --> ex1((D ex1)) -- key --> queue[test_queue] --> sub{{Sub}}
    pub2{{Pub 2}} --> ex2((F ex2)) --> queue
cabbit.queue('test_queue', (msg) => {
    // handle message
    msg.ack();
}).subscribe(cabbit.direct('ex1'), 'key').subscribe(cabbit.fanout('ex2'));

API

See https://artie-owlet.github.io/cabbit/