Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the BullModule in a NestJS module.
NestJS
import { BullModule } from '@nestjs/bull'; @Module({ imports: [BullModule.[1]({ name: 'email' })], }) export class AppModule {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'forRoot' instead of 'register' to register a queue.
Confusing 'registerQueue' with the actual method name.
✗ Incorrect
The correct method to register a queue in BullModule is 'register'.
2fill in blank
mediumComplete the code to inject the queue into a service using constructor injection.
NestJS
import { InjectQueue } from '@nestjs/bull'; import { Queue } from 'bull'; @Injectable() export class EmailService { constructor(@[1]('email') private readonly emailQueue: Queue) {} }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@Inject' instead of '@InjectQueue' for queue injection.
Forgetting to import 'InjectQueue' from '@nestjs/bull'.
✗ Incorrect
Use @InjectQueue decorator to inject a Bull queue by name.
3fill in blank
hardFix the error in the code to add a job to the queue.
NestJS
async sendEmail(data: any) {
await this.emailQueue.[1](data);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'addJob' which is not a method in Bull queue.
Using 'enqueue' or 'push' which are not Bull queue methods.
✗ Incorrect
The correct method to add a job to a Bull queue is 'add'.
4fill in blank
hardFill both blanks to process jobs in a Bull queue with a processor function.
NestJS
@Processor('[1]') export class EmailProcessor { @Process() async handleJob(job: Job) { console.log('Processing job:', job.data); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using class name or method name instead of queue name in @Processor.
Omitting the queue name in the @Processor decorator.
✗ Incorrect
The @Processor decorator takes the queue name to process jobs from that queue.
5fill in blank
hardFill all three blanks to configure BullModule with Redis connection options.
NestJS
BullModule.forRoot({
redis: {
host: '[1]',
port: [2],
password: '[3]',
},
}) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using port as a string instead of a number.
Confusing host with password values.
✗ Incorrect
The Redis host is usually '127.0.0.1', port is 6379, and password can be any string like 'secret123'.