Complete the code to inject the queue producer in the constructor.
constructor(private readonly [1]: Queue) {}In NestJS, the queue producer is typically injected by its token or class name. Here, Queue is the injected type, so the variable name queue is the correct choice.
Complete the code to send a message to the queue.
await this.queue.[1]({ text: 'Hello' });
send which is not a method on the queue producer.publish which is for event emitters.The add method is used in NestJS queue producers to add a job or message to the queue.
Fix the error in the queue producer decorator.
@[1]('email') export class EmailProducer {}
@InjectQueue instead of @QueueProducer.The correct decorator to define a queue producer in NestJS is @QueueProducer('queueName').
Fill both blanks to correctly import and inject the queue.
import { [1] } from '@nestjs/bull'; constructor(@[2]('notifications') private queue: Queue) {}
InjectQueue with QueueProducer.Inject without specifying the queue name.You import InjectQueue from @nestjs/bull and use it as a parameter decorator to inject a named queue.
Fill all three blanks to create a job with a delay and priority.
await this.queue.add('sendEmail', { to: 'user@example.com' }, { [1]: 5000, [2]: [3] });
timeout instead of delay.The options object for adding a job can include delay in milliseconds and priority with values like high.