Registry / messaging / worque

worque

JSON →
library0.11.2jsnpmunverified

A lightweight AMQP-based work queue library (v0.11.2, last updated 2015) for Node.js that provides durable, persistent task processing via RabbitMQ. Key features include one-by-one task processing (RabbitMQ 3.3+), cron scheduling, configurable retry with exponential backoff, and a fluent API using promises. Unlike generic AMQP libraries, worque simplifies task definition and lifecycle management with built-in events and scheduling. It relies on AMQP URLs and uses an event-driven model for task lifecycle. The package is stable but in maintenance mode; no recent updates.

npm install worque
INSTALL
IMPORT
SIG · WORQUE
W
worque
messagingjavascriptv0.11.2
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.

default
import worque from 'worque'
const worque = require('worque')()
ESM default import. Requires AMQP URL string as first argument.
Task
import type { Task } from 'worque'
const Task = require('worque').Task
Type imports only available if package includes types (v0.11.2 does not ship TS types).
subscribe
const client = worque('amqp://localhost'); client('task').subscribe(handler)
const client = require('worque'); client.subscribe('task', handler)
subscribe is a method on the task instance, not on the client.

Sets up a worque client, defines two tasks (immediate and scheduled), publishes a message, and handles graceful shutdown.

import worque from 'worque'; const client = worque('amqp://localhost'); client.on('task', (msg) => console.log('Task received:', msg)); client.on('result', (msg) => console.log('Task completed:', msg)); client.on('failure', (err) => console.error('Task failed:', err)); client('logthis').subscribe((message) => { console.log(message); }); client('logthis').publish({ something: 42 }); client('recurrent task runs each minute').subscribe(() => { console.log('I run each minute'); }).schedule('0 * * * * *'); client('retry 3 times if failed').subscribe((url) => { return doRequestAndSaveToFile(url); }).retry(1, 2, 3).publish('http://mysite.com'); process.on('SIGINT', () => { client.close(); });
Debug
Known issues
gotchaOne-by-one task processing is only guaranteed with RabbitMQ 3.3 and higher.
fix
Upgrade RabbitMQ to 3.3+ or handle concurrency manually.
affects: >=0.0.0
deprecatedPackage uses Bluebird promises internally but does not expose them in the public API.
fix
Use native async/await or your own promise library; avoid relying on Bluebird-specific methods.
affects: >=0.0.0
gotchaAll tasks are processed in the same Node.js process; no built-in distribution across workers.
fix
Implement your own worker pool or use a queue middleware like Bull or Bee-Queue for distributed processing.
affects: >=0.0.0
gotchaThe schedule function uses cron expressions but may not handle timezone offsets; cronjob runs in server local time.
fix
Set the server timezone or adjust your cron expression accordingly.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'worque'
worque not installed or npm install failed.
fix
Run 'npm install worque --save' in your project directory.
Error: connect ECONNREFUSED 127.0.0.1:5672
RabbitMQ is not running or connection URL is wrong.
fix
Start RabbitMQ server or change the AMQP URL to the correct host.
TypeError: client is not a function
Calling require('worque') directly instead of require('worque')(url).
fix
Use const client = require('worque')('amqp://localhost');
Error: task 'name' already has a subscriber
Attempting to subscribe to the same task twice.
fix
Ensure each task has only one subscription, or combine handlers.
Upgrade
Version history
0.11.2latest on npm
Audit
Dependencies
amqplibrequiredAMQP client for RabbitMQ
Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
packageworque
worque — npm install worque · libregistry