0
0
NestJSframework~10 mins

Why background processing handles heavy tasks in NestJS - Test Your Understanding

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

Complete the code to import the module needed for background tasks in NestJS.

NestJS
import { [1] } from '@nestjs/bull';
Drag options to blanks, or click blank then click option'
AConfigModule
BHttpModule
CBullModule
DCacheModule
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated modules like HttpModule or CacheModule.
2fill in blank
medium

Complete the code to register a queue named 'email' for background jobs.

NestJS
BullModule.forRoot({
  redis: {
    host: 'localhost',
    port: 6379,
  },
}),
BullModule.registerQueue('[1]'),
Drag options to blanks, or click blank then click option'
Aemail
Bnotifications
Ctasks
Djobs
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated queue names like 'notifications' or 'jobs'.
3fill in blank
hard

Fix the error in the processor decorator to handle jobs from the 'email' queue.

NestJS
@Processor('[1]')
export class EmailProcessor {
  @Process()
  async handleJob(job: Job) {
    // process job
  }
}
Drag options to blanks, or click blank then click option'
Anotifications
Bjobs
Ctasks
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different queue name than the one registered.
4fill in blank
hard

Fill both blanks to add a job to the 'email' queue with data containing user email.

NestJS
constructor(@InjectQueue('[1]') private emailQueue: Queue) {}

async sendEmail(userEmail: string) {
  await this.emailQueue.add({ [2]: userEmail });
}
Drag options to blanks, or click blank then click option'
Aemail
BemailAddress
CuserEmail
Dnotifications
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong queue names or unclear data keys.
5fill in blank
hard

Fill all three blanks to create a background job processor that logs the job data and marks it complete.

NestJS
@Processor('[1]')
export class LoggerProcessor {
  @Process()
  async handleLog(job: Job<{ [2]: string }>) {
    console.log(job.data.[3]);
  }
}
Drag options to blanks, or click blank then click option'
Alog
Bmessage
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing queue names or data keys causing runtime errors.