0
0
NestJSframework~10 mins

Queue producers in NestJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to inject the queue producer in the constructor.

NestJS
constructor(private readonly [1]: Queue) {}
Drag options to blanks, or click blank then click option'
AqueueService
BproducerQueue
CqueueProducer
Dqueue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that does not match the injected type.
Forgetting to mark the constructor parameter as private readonly.
2fill in blank
medium

Complete the code to send a message to the queue.

NestJS
await this.queue.[1]({ text: 'Hello' });
Drag options to blanks, or click blank then click option'
Apublish
Badd
Csend
Demit
Attempts:
3 left
💡 Hint
Common Mistakes
Using send which is not a method on the queue producer.
Using publish which is for event emitters.
3fill in blank
hard

Fix the error in the queue producer decorator.

NestJS
@[1]('email')
export class EmailProducer {}
Drag options to blanks, or click blank then click option'
AQueueProducer
BProducerQueue
CInjectQueue
DInjectQueueProducer
Attempts:
3 left
💡 Hint
Common Mistakes
Using @InjectQueue instead of @QueueProducer.
Using incorrect decorator names that do not exist.
4fill in blank
hard

Fill both blanks to correctly import and inject the queue.

NestJS
import { [1] } from '@nestjs/bull';

constructor(@[2]('notifications') private queue: Queue) {}
Drag options to blanks, or click blank then click option'
AInjectQueue
BQueueProducer
CInject
DBullModule
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing InjectQueue with QueueProducer.
Using Inject without specifying the queue name.
5fill in blank
hard

Fill all three blanks to create a job with a delay and priority.

NestJS
await this.queue.add('sendEmail', { to: 'user@example.com' }, { [1]: 5000, [2]: [3] });
Drag options to blanks, or click blank then click option'
Adelay
Bpriority
Chigh
Dtimeout
Attempts:
3 left
💡 Hint
Common Mistakes
Using timeout instead of delay.
Setting priority to a number instead of a string like 'high'.