Skip to content
Get started
Get started
Queue Control and Maintenance
guide · queue

Pause it, drain it, wipe it.

The operational verbs. Stop consumption during an incident, clear a backlog, remove finished jobs before they accumulate, and push delayed work forward when you cannot wait.

queue.pause(); // Workers stop pulling (fire-and-forget)
queue.resume(); // Back to normal (fire-and-forget)
queue.drain(); // Remove all waiting jobs (fire-and-forget)
queue.obliterate(); // Remove ALL queue data (fire-and-forget)
await queue.pauseAsync(); // Pause and wait for it
await queue.resumeAsync(); // Resume and wait for it
const n = await queue.drainAsync(); // Drain, wait, get removed count
await queue.obliterateAsync(); // Remove ALL queue data and wait for it
queue.remove('job-id'); // Remove one job (fire-and-forget)
await queue.removeAsync('job-id'); // Remove one job and wait for it
await queue.waitUntilReady(); // Wait until queue/server is ready
queue.close(); // Close TCP connection (no-op in embedded mode)

Gotcha: in TCP mode the fire-and-forget forms return before the server has processed them. If you drain or obliterate and immediately add new jobs, the wipe can land after the add and delete the new job. Use the Async variants when the next step depends on the command being done.

// Remove completed jobs older than 1 hour, max 100 (async works in both modes)
const removed = await queue.cleanAsync(3600000, 100, 'completed');
// Promote delayed jobs to waiting now
const promoted = await queue.promoteJobs({ count: 50 });
// Re-queue failed jobs from the DLQ
await queue.retryJobs({ state: 'failed', count: 100 });
// Re-queue completed jobs through the same selector contract
await queue.retryJobs({
state: 'completed',
count: 100,
timestamp: Date.now() - 3600000, // completed at least one hour ago
});
// Direct completed-job helpers (e.g. after a logic change)
const count = await queue.retryCompletedAsync(); // all completed, use with care
const one = queue.retryCompleted('job-id-123'); // one job (sync, embedded; TCP returns 0)

Bulk retryJobs, retryCompleted, and counted promoteJobs are available in TypeScript and Python; PHP, Go, Rust, and Elixir act per job (promote, retryJob).

Retrying a completed job starts a new waiting execution. Its previous returnvalue, progress/message, processedOn, and finishedOn are cleared; attempts restart at zero, while the diagnostic stacktrace and timeline history remain available. For persisted queues, that reset and removal of the old result are one atomic SQLite transaction and remain cleared after broker restart.

Queue APICreate a queue in embedded or TCP mode
Adding Jobsadd, addBulk, priorities, delays, durability
Deduplication and Idempotent Job AddsIdempotent adds, dedup keys, custom job ids
Querying JobsFetch jobs, states, counts and results
Progress, Job Logs and DependenciesProgress, per-job logs and dependencies
Queue Rate Limiting and Global ConcurrencyRate limits and global concurrency caps
Job Schedulers from the QueueNamed repeatable schedules from the queue
DLQ Operations from the Queue ObjectFailed-job operations from the Queue object
Workers, Stats and Metrics from the QueueRegistered workers, stats and metrics windows
Namespaces, Auto-Batching and Store-and-ForwardNamespaces, auto-batching, store-and-forward
JobOptions ReferenceEvery JobOptions field, with defaults