All 12 ModulesModule 5 of 12
Async Node.js + Worker Queues
Module 5: Asynchronous Automation Job Engine
Build an asynchronous background execution engine returning 202 Accepted, worker task queues, exponential backoff retries, and job state machines.
Node.js EventEmitterHTTP 202 AcceptedWorker ThreadsExponential BackoffIdempotency KeysState MachinePolling & WebSockets
Level 1: Build
Level 1: Build — Non-Blocking Job Engine
Construct an async job processing pipeline that dispatches heavy router configuration jobs without blocking HTTP request threads.
User Story:
As a Network Engineer, I need to push VLAN configurations across 50 switches simultaneously without my browser timing out.
Key Deliverables & Specifications:
- REST endpoint returning 202 Accepted with `Location: /api/jobs/:id` header
- In-memory / BullMQ Task Queue with concurrency worker limits
- Job State Machine: PENDING → RUNNING → COMPLETED | FAILED | TIMED_OUT
- Idempotency Key validation preventing duplicate job dispatch on network retries
Implementation Roadmap:
1. **Receive Job**: Validate DTO and check for `Idempotency-Key` in headers.
2. **Persist & Acknowledge**: Save job with `PENDING` status and return `202 Accepted`.
3. **Queue Processing**: Worker picks up job, marks `RUNNING`, and executes commands with exponential backoff.
4. **Finalize**: Update job result and emit completion event.