0
0
NestJSframework~20 mins

Queue events and monitoring in NestJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Queue Events and Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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'.
AJob 42 completed
BJob completed with result: Email sent
CJob 42 completed with result: Email sent
DJob completed
Attempts:
2 left
💡 Hint
Look at how the job ID and return value are accessed in the event listener.
🧠 Conceptual
intermediate
1: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?
A'failed'
B'waiting'
C'completed'
D'active'
Attempts:
2 left
💡 Hint
Retry logic is triggered when a job does not succeed.
Configuration
advanced
3: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());
AUse BullModule.forRoot({ monitor: true }) without additional setup
BInstall 'bull-monitor' package and import it in main.ts without further config
CAdd 'monitoring: true' in queue options in BullModule.registerQueue
DUse BullModule.registerQueue({ name: 'myQueue' }) and set up Bull Board with ExpressAdapter as shown
Attempts:
2 left
💡 Hint
Bull Board requires explicit setup with adapters and routes.
Troubleshoot
advanced
2: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?
ARedis server is down
BThe event listener is added after jobs are processed
CThe queue processor function does not return a value
DThe queue is not registered with BullModule
Attempts:
2 left
💡 Hint
Check the timing of when the event listener is added relative to job processing.
Best Practice
expert
3: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?
AUse the 'failed' event to send alerts to an external monitoring service like Sentry or Datadog
BLog failures to console and check logs manually
CIgnore failures and rely on retries only
DRestart the queue worker process on any failure
Attempts:
2 left
💡 Hint
Automated alerting helps catch issues early.