Skip to main content
Job producers add jobs to queues in NestJS. Producers are typically application services (Nest providers) that inject queues to add jobs.

Basic Producer

1

Inject the queue into your service

Use the @InjectQueue() decorator to inject a queue by name:
The @InjectQueue() decorator identifies the queue by its name, as provided in registerQueue().
2

Add jobs to the queue

Call the queue’s add() method to add jobs:

Complete Producer Example

audio.service.ts

Job Options

Customize job behavior with various options:

Flow Producers

For complex workflows with parent-child job relationships, use FlowProducer:
1

Register the FlowProducer

2

Inject the FlowProducer

The @InjectFlowProducer() decorator identifies the flow producer by its name, as provided in registerFlowProducer().
3

Create a flow

Bulk Job Operations

Add multiple jobs efficiently:

Controller Example

Integrate producers with NestJS controllers:
audio.controller.ts

Best Practices

Job IDs

Use custom job IDs for deduplication:

Error Handling

Always handle errors when adding jobs:

Job Options

Set appropriate timeouts and attempts:

Auto-removal

Clean up completed jobs automatically:

NestJS Integration

Learn about NestJS integration basics

Queue Events

Listen to queue events in NestJS

External Documentation

NestJS Queues Documentation

Official NestJS documentation for queue integration