Job Queue Lite
Enqueue jobs in Redis/memory, drain via a Cron-style Route Handler, and watch progress in the UI.
Run this experiment yourself
Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.
Local development
cd apps/experiments/job-queue-lite pnpm install pnpm dev
Then open http://localhost:3010.
This is an experimental demo. Use it as a starting point for your own projects.
Job Queue Lite enqueues string payloads into Redis (or process memory), advances one job per drain step via Cron/?run=1, and shows a progress UI. Include fail-me in a payload to simulate failure.
Features
- Enqueue – Redis list-as-JSON or shared memory store.
- Drain – Cron Route Handler advances progress in chunks.
- Progress UI – status, percent bar, error text.
- Honest note when Redis is missing.
API Reference
POST /api/queue
{ "payload": "resize-avatar:user-42" }GET /api/queue
Lists jobs (storage: redis | memory).
GET /api/drain?run=1 / POST /api/drain
Drains one step. Production requires Authorization: Bearer CRON_SECRET.
| Status | Cause |
|---|---|
400 | Missing payload |
401 | Cron auth failed |
Implementation Details
Enqueue
Validate/truncate payload, append queued job, persist.
Drain
pickNextQueued + advanceJob in logic.ts — pure progress math for tests.
Use Cases
- Teach Cron workers without a full queue product.
- Prototype job progress UX.
- Compare with Vercel Queues (
queues-lab).
Limitations
- Not a durable multi-instance queue without Redis.
- Single-step drain is intentional (demo clarity).
- No retries/backoff beyond the simulated failure path.
Use in your project
Copy handlers and logic.ts from apps/experiments/job-queue-lite/.
Deployment
Local Development
cd apps/experiments/job-queue-lite
pnpm install
pnpm devConfiguration
| Variable | Required | Purpose |
|---|---|---|
UPSTASH_REDIS_REST_URL / TOKEN | No | Durable queue |
CRON_SECRET | Prod cron | Authorize drain |
Vercel / Next.js Features Used
- Upstash Redis
- Vercel Cron
- Route Handlers