Registry / messaging / bunnybus

bunnybus

JSON →
library7.0.0jsnpmunverified

BunnyBus is a high-level enterprise bus library for RabbitMQ that simplifies pub/sub and queue management by abstracting connection, channel, binding, and subscription creation. The current stable version is 7.0.0, released with Node.js >=14 support and maintained by XO Group. It offers both callback and Promise APIs, with optional strict FIFO ordering (at a performance cost). Unlike lower-level RabbitMQ libraries, BunnyBus provides safe defaults, native callbacks for performance, and a built-in error queue / retry management system. It is designed for production messaging patterns requiring reliable delivery and easy configuration.

npm install bunnybus
INSTALL
IMPORT
SIG · BUNNYBUS
B
bunnybus
messagingjavascriptv7.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BunnyBus
const BunnyBus = require('bunnybus');
import BunnyBus from 'bunnybus';
Package uses CommonJS; no default ESM export.
BunnyBus constructor (with config)
const BunnyBus = require('bunnybus'); const bus = new BunnyBus({ server: { host: 'localhost' } });
const BunnyBus = require('bunnybus').BunnyBus;
Module exports the class directly, not as a named export.
Constants
const { Events, DeliveryTypes } = require('bunnybus/lib/constants');
Constants are accessed via lib path; not exposed at the top level.
TypeScript types
import { BunnyBus } from 'bunnybus';
Limited TypeScript support; types may be missing. Use @types/bunnybus if available.

Demonstrates subscribing to a queue and publishing a message with async/await.

const BunnyBus = require('bunnybus'); const bus = new BunnyBus(); async function main() { await bus.subscribe('myQueue', { 'myEvent': async (message, ack) => { console.log('Received:', message.data); await ack(); } }); await bus.publish({ event: 'myEvent', data: 'Hello World!' }); console.log('Message published'); // Cleanup after a moment setTimeout(async () => { await bus.close(); process.exit(0); }, 1000); } main().catch(err => { console.error(err); process.exit(1); });
Debug
Known issues
breakingv6 to v7: Removed support for Node.js <14 and dropped callback-only API in favor of promises.
fix
Upgrade to Node.js >=14 and migrate to async/await or use .then()/.catch().
affects: >=6.0.0 <7.0.0
gotchaPublished messages must contain an 'event' property; otherwise, subscription handlers won't fire.
fix
Always include an 'event' string in the message object when publishing.
affects: *
gotchaCalling ack() is required; failing to do so may cause message redelivery and memory leaks.
fix
Always call ack() after successful processing, or use nack() for failures.
affects: *
gotchaStrict FIFO (serial dispatch) significantly reduces throughput; enable only when order is critical.
fix
Set server.dispatchType to 'serial' in config only if strict ordering is required.
affects: *
Errors
Common errors & fixes
Error: connect ECONNREFUSED 127.0.0.1:5672
RabbitMQ server is not running or unreachable.
fix
Start RabbitMQ locally or configure the server host/port in the BunnyBus constructor.
TypeError: bus.subscribe is not a function
Using require incorrectly (e.g., destructured wrong).
fix
Use correct import: const BunnyBus = require('bunnybus'); const bus = new BunnyBus();
Error: Channel closed by server: 406 PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'myQueue'
Attempting to redeclare a queue with different properties (e.g., durable vs non-durable).
fix
Ensure queue configuration matches existing queue or delete the queue before redefining.
UnhandledPromiseRejectionWarning: Error: Cannot read property 'ack' of undefined
Handler function does not receive an ack callback when using older API or misconfigured subscription.
fix
Ensure subscription handlers accept (message, ack) parameters and use async/await with the ack.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
amqplibrequiredRabbitMQ driver for AMQP protocol
Agent activity
32 hits · last 30 days
node
28
OpenAI (training)
1
Resources
bunnybus — npm install bunnybus · libregistry