Registry / messaging / peanar

peanar

JSON →
library0.18.1jsnpmunverified

Peanar is a robust job queue for Node.js built on RabbitMQ, providing reliable background job processing with features like delayed jobs, job retries, and concurrency control. The current stable version is 0.18.1, released on an irregular cadence. It is designed for production use and has been running in production at rechat.com for over a year. Unlike Redis-based queues, Peanar leverages RabbitMQ's AMQP 0-9-1 protocol for reliable message delivery, making it suitable for environments where RabbitMQ is already in use.

npm install peanar
INSTALL
IMPORT
SIG · PEANAR
P
peanar
messagingjavascriptv0.18.1
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.

peanar
import peanar from 'peanar'
const peanar = require('peanar')
Default export; ESM-compatible with TypeScript
Job
import { Job } from 'peanar'
const { Job } = require('peanar')
Named export for defining job classes
JobQueue
import { JobQueue } from 'peanar'
Named export for custom queue configuration

Demonstrates setting up a Peanar queue, defining a job class, enqueuing a job, and starting a worker to process jobs.

import peanar, { Job } from 'peanar'; import amqplib from 'amqplib'; const connection = await amqplib.connect('amqp://guest:guest@localhost'); const channel = await connection.createChannel(); const queue = peanar({ name: 'myQueue', connection, channel, }); class MyJob extends Job { static perform(params: { message: string }) { console.log(`Processing: ${params.message}`); } } queue.enqueue(MyJob, { message: 'Hello from Peanar!' }); const worker = queue.worker(); worker.start();
Debug
Known issues
gotchaRabbitMQ must be running and accessible; the library will fail silently if connection fails.
fix
Ensure RabbitMQ server is available and connection URL is correct.
affects: >=0.0.0
breakingIn version 0.18.0, the API changed: 'peanar' now returns a queue instance instead of a factory.
fix
Update code to call peanar(options) directly instead of peanar.createQueue(options).
affects: >=0.18.0 <0.19.0
gotchaJob class must have a static 'perform' method; otherwise jobs will fail silently.
fix
Ensure every Job subclass defines static perform(params).
affects: >=0.0.0
deprecatedThe 'channel' option is required; omitting it will cause errors in future versions.
fix
Provide a channel object to peanar options.
affects: >=0.17.0
Errors
Common errors & fixes
TypeError: peanar is not a function
Using require() with default import in an ESM context.
fix
Use import peanar from 'peanar' or use require('peanar').default.
Error: Job must have a static 'perform' method
Job class does not implement static perform.
fix
Add static perform(params) method to the job class.
Error: Connection closed unexpectedly
RabbitMQ connection lost due to network or server issue.
fix
Implement reconnection logic or use a connection manager.
Upgrade
Version history
0.18.1latest on npm
Audit
Dependencies
amqplibrequiredRequired for RabbitMQ connection and channel management
@types/amqpliboptionalTypeScript type definitions for amqplib
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
packagepeanar