Registry / devops / amqp-queue

amqp-queue

JSON →
library1.2.4jsnpmunverified

AMQP-based job queue with Redis-backed job status tracking (inactive, active, complete, error, progress). Current version 1.2.4, weekly releases. Differentiators: integrates AMQP for message routing/persistence while using Redis solely for monitoring job states across queues. Supports lightweight mode to skip monitoring for high-throughput jobs. Good for simple distributed job processing with visibility into job lifecycle.

npm install amqp-queue
INSTALL
IMPORT
SIG · AMQP-QUEUE
A
amqp-queue
devopsjavascriptv1.2.4
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.

Queue
import { Queue } from 'amqp-queue'
const Queue = require('amqp-queue').Queue
ESM-only since v1.0, default export not available
Queue
import { Queue } from 'amqp-queue'
import Queue from 'amqp-queue'
Must use named import
Job
import { Job } from 'amqp-queue'
const { Job } = require('amqp-queue')
TypeScript types included, import Job for type annotations

Sets up AMQP queue and Redis client, creates a job, processes it with progress tracking, and handles complete/error events.

import { Queue } from 'amqp-queue'; import { connect } from 'amqplib'; import { createClient } from 'redis'; async function main() { const amqpConn = await connect(process.env.AMQP_URL ?? 'amqp://localhost'); const redisClient = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }); await redisClient.connect(); const queue = new Queue({ amqp: amqpConn, redis: redisClient }); await queue.setup({ mainQueue: 'tasks' }); queue.process(async (job) => { console.log(`Processing job ${job.id}: ${JSON.stringify(job.data)}`); job.progress(50); return { result: 'done' }; }); const job = await queue.create({ task: 'example' }); console.log(`Created job ${job.id}`); queue.on('complete', (job) => { console.log(`Job ${job.id} completed`); }); queue.on('error', (job, err) => { console.error(`Job ${job.id} failed: ${err.message}`); }); } main().catch(console.error);
Debug
Known issues
gotchaJob status in Redis is only updated for non-lightweight jobs; lightweight jobs bypass Redis entirely, making them unmonitorable.
fix
Ensure lightweight:true is only used when monitoring is not needed, or omit to track status.
affects: >=1.0.0
deprecatedThe constructor option 'redis' was deprecated in v1.1.0; use 'redisClient' instead.
fix
Replace 'redis' with 'redisClient' in Queue constructor options.
affects: >=1.1.0
breakingIn v1.2.0, the 'setup' method no longer accepts a queue name string; it requires an options object with 'mainQueue' property.
fix
Change queue.setup('myqueue') to queue.setup({ mainQueue: 'myqueue' }).
affects: >=1.2.0
gotchaThe 'progress' method on Job objects is only available after the job has started processing; calling it before yields no effect.
fix
Only call job.progress() inside the process handler.
affects: >=1.0.0
gotchaAMQP connection and Redis client must be connected before instantiating Queue; otherwise setup will fail with a connection error.
fix
Always await amqpConn.connect() and redisClient.connect() before new Queue(...).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: queue.setup is not a function
Imported default export instead of named export.
fix
Use `import { Queue } from 'amqp-queue'` instead of `import Queue from 'amqp-queue'`.
Error: Redis client is not connected
Queue instantiated before Redis client is connected.
fix
Await redisClient.connect() before creating Queue instance.
Error: job.progress is not a function
Called progress outside of process handler.
fix
Only use job.progress() inside the callback passed to queue.process().
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
amqplibrequiredAMQP protocol client for RabbitMQ messaging
redisrequiredRedis client for job status storage
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
amqp-queue — npm install amqp-queue · libregistry