Complete the code to define a named job in a NestJS Bull queue.
this.queue.add('[1]', { data: payload });
The first argument to add is the job name, here 'sendEmail'.
Complete the code to process a named job in a NestJS Bull processor.
@Processor('email') export class EmailProcessor { @Process('[1]') handleSendEmail(job: Job) { // handle job } }
The @Process decorator takes the job name to handle, matching the name used when adding the job.
Fix the error in the code to correctly add a named job with options.
this.queue.add([1], payload, { repeat: { cron: '0 0 * * *' } });
The job name must be a string, so it needs quotes around it.
Fill both blanks to define and process a named job in NestJS Bull.
this.queue.add('[1]', { userId: 123 }); @Processor('notifications') export class NotificationProcessor { @Process('[2]') handleNotification(job: Job) { // process notification } }
The job name must be the same when adding and processing. Here, 'sendNotification' is used consistently.
Fill all three blanks to add a named job with options and process it in NestJS Bull.
this.queue.add('[1]', { orderId: 456 }, { delay: [2] }); @Processor('orders') export class OrderProcessor { @Process('[3]') handleOrder(job: Job) { // process order } }
The job name 'processOrder' is used consistently. The delay option is a number in milliseconds (5000 = 5 seconds).