0
0
NestJSframework~20 mins

Named jobs in NestJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Named Jobs Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when a named job is added twice with the same name?

Consider a NestJS Bull queue where you add a named job twice with the same name but different data. What will be the behavior?

NestJS
await queue.add('email', { to: 'a@example.com' });
await queue.add('email', { to: 'b@example.com' });
AThe second job replaces the first job in the queue.
BBoth jobs are added separately and processed independently.
COnly the first job is added; the second is ignored silently.
DAn error is thrown because job names must be unique.
Attempts:
2 left
💡 Hint

Think about how queues handle jobs with the same name but different data.

📝 Syntax
intermediate
2:00remaining
Which code correctly adds a named job with repeat options in NestJS Bull?

Choose the correct syntax to add a named job called 'cleanup' that repeats every hour.

Aawait queue.add('cleanup', {}, { repeat: { cron: '0 * * * *' } });
Bawait queue.add({ name: 'cleanup', data: {}, repeat: { cron: '0 * * * *' } });
Cawait queue.add('cleanup', {}, { repeat: '0 * * * *' });
Dawait queue.add('cleanup', { repeat: { cron: '0 * * * *' } });
Attempts:
2 left
💡 Hint

Remember the method signature: add(name, data, options).

🔧 Debug
advanced
2:00remaining
Why does this named job never run in NestJS Bull?

Given the following code, why does the named job 'processData' never execute?

NestJS
queue.process('processData', async (job) => {
  console.log('Processing:', job.data);
});

await queue.add('processdata', { id: 1 });
AThe process() method is missing a concurrency parameter, so it never runs.
BThe job data is missing required fields, so the job is skipped.
CThe job name in add() is lowercase 'processdata', but process() listens for 'processData' (case mismatch).
DThe queue is not started, so no jobs run.
Attempts:
2 left
💡 Hint

Check the exact spelling and casing of job names.

state_output
advanced
2:00remaining
What is the job count after adding and removing named jobs?

Consider this sequence:

await queue.add('task1', {});
await queue.add('task2', {});
const job = await queue.getJob('task1');
await job?.remove();
const count = await queue.count();

What is the value of count?

A2
BThrows an error because getJob expects a job ID, not a name.
C0
D1
Attempts:
2 left
💡 Hint

Check the parameter type expected by getJob().

🧠 Conceptual
expert
3:00remaining
How does Bull handle concurrency for named jobs in NestJS?

In NestJS Bull, if you define multiple processors for the same named job with different concurrency values, what happens?

ABull throws an error because multiple processors for the same job name are not allowed.
BBull uses the highest concurrency value among processors for that job name.
COnly the first registered processor runs; others are ignored.
DBull runs all processors in parallel, each with its own concurrency setting.
Attempts:
2 left
💡 Hint

Think about how Bull distributes jobs to processors.