0
0
NestJSframework~10 mins

Bull queue integration in NestJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AregisterQueue
Bregister
CforRoot
DforFeature
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'forRoot' instead of 'register' to register a queue.
Confusing 'registerQueue' with the actual method name.
2fill in blank
medium

Complete 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'
AInjectQueue
BInject
CInjectable
DInjectService
Attempts:
3 left
💡 Hint
Common Mistakes
Using '@Inject' instead of '@InjectQueue' for queue injection.
Forgetting to import 'InjectQueue' from '@nestjs/bull'.
3fill in blank
hard

Fix 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'
AaddJob
Benqueue
Cadd
Dpush
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.
4fill in blank
hard

Fill 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'
Aemail
BsendEmail
CEmailProcessor
DjobProcessor
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.
5fill in blank
hard

Fill 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'
Alocalhost
B6379
Csecret123
D127.0.0.1
Attempts:
3 left
💡 Hint
Common Mistakes
Using port as a string instead of a number.
Confusing host with password values.