NestJS · Middle · Question 36 of 75
How do you move slow work, like sending emails, to a background queue in Nest?
- 1Use
setTimeoutin the controller - 2Use
@Cronfor every email - ✓Correct answer: Use
@nestjs/bullmq: add jobs with an injected queue and process them in a@Processor()class
Explanation
Jobs survive restarts in Redis, can be retried with backoff and processed by separate worker instances.