对于后台任务(不应阻塞 HTTP 响应的工作),NestJS 通过 @nestjs/bullmq 与BullMQ(Redis 支持的队列)集成。你将任务添加到队列中,并在单独的 worker 中异步处理它们——保持请求快速响应,并可靠地处理繁重或延迟的工作。
队列解决的问题
text
Some work is too slow or shouldn't block the request:
✗ sending emails, processing images/video, generating reports, calling slow APIs
→ doing it inline makes the user wait and risks timeouts/failures
✓ QUEUE the work → respond immediately → a worker processes it in the background
