0
0
NestJSframework~20 mins

Job options (delay, attempts, priority) in NestJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bull Job Options Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2: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 });
AThe job will wait 5 seconds before it becomes eligible for processing.
BThe job will be retried 5 times with 1 second delay between retries.
CThe job will be assigned the highest priority and processed first.
DThe job will start processing immediately after being added to the queue.
Attempts:
2 left
💡 Hint
Think about what the delay option controls in job scheduling.
state_output
intermediate
2: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 });
AThe processor will run 1 time only.
BThe processor will run 2 times total.
CThe processor will run 4 times total.
DThe processor will run 3 times total.
Attempts:
2 left
💡 Hint
Remember that attempts count includes the first try plus retries.
📝 Syntax
advanced
2: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 }, ???);
A{ priority: 10 }
B{ priority: '10' }
C{ priority: true }
D{ priority: -10 }
Attempts:
2 left
💡 Hint
Priority should be a positive integer number.
🔧 Debug
advanced
2: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 });
ARangeError: Delay must be a positive integer
BTypeError: Delay option must be a string
CNo error, job will be processed immediately
DSyntaxError: Unexpected token '-'
Attempts:
2 left
💡 Hint
Think about what negative delay means for scheduling.
🧠 Conceptual
expert
3: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 });
Ajob3, job1, job2
Bjob2, job1, job3
Cjob1, job2, job3
Djob1, job3, job2
Attempts:
2 left
💡 Hint
Higher priority numbers mean higher priority in Bull.