@domusjs/jobs — Introduction
The Jobs Module in DomusJS provides a structured, scalable system to manage background processing using BullMQ.
✅ It enables you to queue tasks, run workers, and process jobs asynchronously outside the main request/response flow.
Use it for:
- Heavy computations.
- Asynchronous tasks (e.g., sending emails, processing videos).
- Delayed or scheduled work.
- Parallel task execution.
Why Use the Jobs Module?
Section titled “Why Use the Jobs Module?”Scenario | Should Use Jobs? |
---|---|
Send an email after user registration | ✅ Yes |
Process uploaded video files | ✅ Yes |
Run a task every day at 2 AM | ❌ No (use Cron) |
React to domain events | ✅ Yes (via jobs) |
✅ The Jobs Module is ideal when you need to offload heavy or slow work from the main app flow.
Benefits
Section titled “Benefits”✅ Asynchronous & Scalable → Process thousands of jobs in parallel.
✅ Separation of Concerns → Keep slow tasks away from user-facing logic.
✅ Extensible → Plug in custom queues, workers, and handlers.
✅ Observable → Integrate with monitoring tools and track job lifecycles.