Challenge - 5 Problems
Bull Job Options Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
Understanding delay option in NestJS Bull jobs
What will be the behavior of a job scheduled with a delay of 5000 milliseconds in NestJS Bull queue?
NestJS
queue.add('sendEmail', { userId: 123 }, { delay: 5000 });
Attempts:
2 left
💡 Hint
Think about what the delay option controls in job scheduling.
✗ Incorrect
The delay option specifies how long the job should wait before it is processed. A delay of 5000 means the job will be delayed for 5 seconds.
❓ state_output
intermediate2:00remaining
Effect of attempts option on job retries
If a job is configured with { attempts: 3 } and it fails twice before succeeding, how many times will the job processor run?
NestJS
queue.add('processData', { data: 'info' }, { attempts: 3 });
Attempts:
2 left
💡 Hint
Remember that attempts count includes the first try plus retries.
✗ Incorrect
The attempts option sets the maximum number of tries including the first attempt. So 3 attempts means the job can run up to 3 times if it keeps failing.
📝 Syntax
advanced2:00remaining
Correct syntax for setting job priority in NestJS Bull
Which option correctly sets a job priority of 10 when adding a job to a Bull queue in NestJS?
NestJS
queue.add('generateReport', { reportId: 42 }, ???);
Attempts:
2 left
💡 Hint
Priority should be a positive integer number.
✗ Incorrect
The priority option expects a positive integer. Strings or booleans are invalid and negative numbers lower priority.
🔧 Debug
advanced2:00remaining
Identifying error with invalid delay value
What error will occur if you set delay to a negative number like -1000 in a Bull job options?
NestJS
queue.add('cleanup', {}, { delay: -1000 });
Attempts:
2 left
💡 Hint
Think about what negative delay means for scheduling.
✗ Incorrect
Bull does not throw an error for negative delay values. The job timestamp will be in the past, causing it to be processed immediately.
🧠 Conceptual
expert3:00remaining
How priority affects job processing order in Bull queues
Given three jobs added with priorities 5, 10, and 1 respectively, in what order will Bull process them assuming no delay or attempts?
NestJS
queue.add('job1', {}, { priority: 5 }); queue.add('job2', {}, { priority: 10 }); queue.add('job3', {}, { priority: 1 });
Attempts:
2 left
💡 Hint
Higher priority numbers mean higher priority in Bull.
✗ Incorrect
Bull processes jobs with higher priority numbers first. So priority 10 runs before 5, which runs before 1.