Challenge - 5 Problems
Bull Queue Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when a job is added to a Bull queue in NestJS?
Consider a NestJS service that adds a job to a Bull queue using
this.queue.add('email', { userId: 123 }). What is the immediate behavior after this call?NestJS
import { Injectable } from '@nestjs/common'; import { InjectQueue } from '@nestjs/bull'; import { Queue } from 'bull'; @Injectable() export class EmailService { constructor(@InjectQueue('email') private readonly queue: Queue) {} async sendWelcomeEmail(userId: number) { await this.queue.add('sendEmail', { userId }); } }
Attempts:
2 left
💡 Hint
Think about how queues work to handle tasks in the background.
✗ Incorrect
In Bull with NestJS, adding a job to the queue schedules it for asynchronous processing by a worker. The method call returns after adding the job, not after processing it.
📝 Syntax
intermediate2:00remaining
Which code snippet correctly defines a Bull queue processor in NestJS?
You want to create a processor that handles jobs from the 'email' queue. Which option shows the correct way to define this processor?
Attempts:
2 left
💡 Hint
Look for the decorator that marks a class as a queue processor and the method decorator for job types.
✗ Incorrect
The @Processor decorator marks the class as a Bull queue processor. The @Process decorator marks methods that handle specific job types.
❓ state_output
advanced2:00remaining
What is the state of a Bull job after successful completion?
After a job is processed successfully by a Bull queue worker in NestJS, what is the job's state when you check it using
job.getState()?Attempts:
2 left
💡 Hint
Think about the lifecycle states of a job in Bull after finishing without errors.
✗ Incorrect
When a job finishes successfully, its state is "completed". "active" means currently processing, "failed" means error, and "waiting" means queued but not started.
🔧 Debug
advanced2:00remaining
Why does this Bull queue processor never process jobs?
Given this NestJS Bull processor code, why are jobs never processed?
import { Processor, Process } from '@nestjs/bull';
import { Job } from 'bull';
@Processor('email')
export class EmailProcessor {
@Process('sendEmail')
async handleSendEmail() {
console.log('Processing email job');
}
}Attempts:
2 left
💡 Hint
Check the method signature for required parameters.
✗ Incorrect
The handler method must accept a Job parameter to receive job data. Without it, the method signature is invalid and the job is not processed.
🧠 Conceptual
expert2:00remaining
How does Bull queue handle job retries in NestJS?
You want a job to retry automatically up to 3 times if it fails. Which configuration option achieves this behavior when adding a job to a Bull queue?
Attempts:
2 left
💡 Hint
Look for the official Bull option name for retry attempts.
✗ Incorrect
The correct option to specify retry attempts in Bull is 'attempts'. Other options are invalid and will be ignored.