Bull Job Queue

A scalable and developer-ready background job queue system built on Bull and Redis. Supports retries, delays, dashboards, and REST control.

bullredisqueuejobsexpressbackgroundscheduler
v2.0.0utility

Overview

A robust, fault-tolerant job queue component for Express applications powered by Bull and Redis. Enables background processing, scheduled tasks, automatic retries, and includes a real-time web dashboard (Bull Board) for monitoring. Perfect for sending emails, processing uploads, caching, notifications, and other async workloads.

Installation

CLI
npx backternity add job-queue-bull

What This Does

Installs a complete Bull + Redis job queue system with REST endpoints, retry logic, and a Bull Board admin dashboard.

Files & Folders Created

File / PathDescription
/src/config/queue.jsConfigures Bull and Redis connection.
/src/routes/jobs.jsREST API routes for job management.
/src/services/jobService.jsAdd, fetch, and retry jobs.
/src/config/dashboard.jsBull Board web UI setup.
/.env.exampleRedis connection and queue settings.

Files to be modified

File / PathDescription
server.jsMounts /api/jobs and /admin/queues routes.
.envAdds Redis and queue configuration.

Configuration

# Redis Configuration
REDIS_HOST=127.0.0.1
REDIS_PORT=6379

# Queue Settings
QUEUE_NAME=background-jobs
MAX_RETRIES=3
PORT=3001

Frontend Integration

Use this component with your frontend (Next.js or React) to enqueue background jobs like sending emails, generating reports, or processing uploads. You can also monitor job progress using the built-in Bull Board UI.

POST/api/jobs/add

Adds a new job to the queue with optional delay or retries.

GET/api/jobs/status/job_64f8a4b2c1234567890abcde

Retrieves the status and result of a specific job.

POST/api/jobs/retry-failed

Retries all failed jobs currently in the queue.

GET/api/jobs/stats

Get queue statistics and job counts.

Example

1// app/jobs/EnqueueJob.jsx (Next.js example) 2'use client'; 3import { useState } from 'react'; 4 5export default function EnqueueJob() { 6 const [jobId, setJobId] = useState(null); 7 const [status, setStatus] = useState(''); 8 9 async function enqueueEmailJob() { 10 setStatus('Submitting job...'); 11 try { 12 const res = await fetch('/api/jobs/add', { 13 method: 'POST', 14 headers: { 'Content-Type': 'application/json' }, 15 body: JSON.stringify({ task: 'sendEmail', email: 'user@example.com' }), 16 }); 17 const data = await res.json(); 18 if (data.success) { 19 setJobId(data.jobId); 20 setStatus('✅ Job queued successfully!'); 21 } else { 22 setStatus('⚠️ Failed to queue job'); 23 } 24 } catch (err) { 25 setStatus('❌ Error connecting to job queue'); 26 } 27 } 28 29 async function checkStatus() { 30 if (!jobId) return; 31 const res = await fetch('/api/jobs/status/' + jobId); 32 const data = await res.json(); 33 alert(JSON.stringify(data.status, null, 2)); 34 } 35 36 return ( 37 <div className="p-4 border border-white/10 rounded-lg bg-black/30"> 38 <button 39 onClick={enqueueEmailJob} 40 className="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded font-medium" 41 > 42 Queue Email Job 43 </button> 44 45 {jobId && ( 46 <button 47 onClick={checkStatus} 48 className="ml-3 bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-2 rounded font-medium" 49 > 50 Check Job Status 51 </button> 52 )} 53 54 <p className="text-sm text-gray-400 mt-3">{status}</p> 55 <p className="text-xs text-gray-500 mt-1"> 56 🔍 Monitor queue: <a href="/admin/queues" className="underline">Bull Board Dashboard</a> 57 </p> 58 </div> 59 ); 60}

Usage

1// Enqueue and monitor background jobs 2const { addJob, getJobStatus } = require('./src/services/jobService'); 3 4// Add new job 5const job = await addJob({ task: 'emailReport', to: 'user@example.com' }); 6 7// Check status 8const status = await getJobStatus(job.id); 9console.log(status);

Get in Touch

For partnerships, collaborations, or custom backend components - let’s build something powerful together.

Send us a message

Reach us directly

Email

team@backternity.dev

Quick Answers

Are components free?

Yes, they’re absolutely free to use.

Do you offer custom work?

Absolutely, we build scalable backend systems tailored to your stack.

How often are updates released?

Monthly, with new components, optimizations, and features.

Bull Job Queue – Utility Component | Backternity