Challenge - 5 Problems
Queue Events and Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output when a job is completed in a NestJS queue?
Consider a NestJS queue with an event listener for the 'completed' event. What will be logged when a job with ID 42 completes successfully?
NestJS
queue.on('completed', (job) => { console.log(`Job ${job.id} completed with result: ${job.returnvalue}`); }); queue.add({ task: 'sendEmail' }); // Assume job with ID 42 completes with returnvalue 'Email sent'.
Attempts:
2 left
💡 Hint
Look at how the job ID and return value are accessed in the event listener.
✗ Incorrect
The 'completed' event listener receives the job object. Accessing job.id and job.returnvalue gives the job's ID and result. The console.log prints both.
🧠 Conceptual
intermediate1:30remaining
Which event should you listen to for retrying failed jobs in NestJS queues?
You want to retry jobs automatically when they fail in a NestJS queue. Which event is best to listen for to trigger retry logic?
Attempts:
2 left
💡 Hint
Retry logic is triggered when a job does not succeed.
✗ Incorrect
The 'failed' event fires when a job fails. Listening to it allows you to implement retry logic.
❓ Configuration
advanced3:00remaining
How to enable detailed queue monitoring with Bull in NestJS?
Which configuration snippet correctly enables the built-in UI dashboard for Bull queue monitoring in a NestJS app?
NestJS
import { BullModule } from '@nestjs/bull'; import { createBullBoard } from '@bull-board/api'; import { BullAdapter } from '@bull-board/api/bullAdapter'; import { ExpressAdapter } from '@bull-board/express'; const serverAdapter = new ExpressAdapter(); createBullBoard({ queues: [new BullAdapter(myQueue)], serverAdapter }); app.use('/admin/queues', serverAdapter.getRouter());
Attempts:
2 left
💡 Hint
Bull Board requires explicit setup with adapters and routes.
✗ Incorrect
Bull Board is a separate UI dashboard for Bull queues. It requires registering queues and mounting its router in the app.
❓ Troubleshoot
advanced2:30remaining
Why does the 'completed' event not fire in a NestJS Bull queue?
You added a listener for the 'completed' event on a Bull queue in NestJS, but it never triggers even though jobs finish successfully. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check the timing of when the event listener is added relative to job processing.
✗ Incorrect
Event listeners must be added before jobs are added and processed. If added after jobs complete, the event is missed even if jobs succeed.
✅ Best Practice
expert3:00remaining
What is the best practice for monitoring job failures in production NestJS queues?
In a production NestJS app using Bull queues, what is the best practice to monitor and alert on job failures?
Attempts:
2 left
💡 Hint
Automated alerting helps catch issues early.
✗ Incorrect
Listening to 'failed' events and sending alerts to monitoring tools ensures prompt detection and response to job failures.