Skip to main content

Creating a Queue

Queues are used to add jobs that will be processed by workers:

Adding Jobs

Basic Job

Delayed Job

Job with Options

Job Deduplication

Prevent duplicate jobs from being added to the queue:

Simple Deduplication

Throttle Mode

Debounce Mode

Creating a Worker

Workers process jobs from the queue using a processor function:

Worker Options

Job Progress

Update job progress from within the processor:

Error Handling

Recoverable Errors

Unrecoverable Errors

Connection Options

Using Connection String

Local Redis

Complete Example

Here’s a complete example combining queue and worker:

Interoperability

Jobs added with Python can be processed by workers in other languages: Node.js Worker:
Elixir Worker:

Best Practices

  1. Always close connections - Call await queue.close() and await worker.close() when done
  2. Use meaningful job names - Makes debugging and monitoring easier
  3. Set appropriate retry attempts - Not all jobs should retry infinitely
  4. Use deduplication - Prevent duplicate jobs when idempotency is important
  5. Handle errors gracefully - Distinguish between recoverable and unrecoverable errors
  6. Monitor job progress - Use progress updates for long-running jobs

View Changelog

See what’s new in the latest version