Backend Boilerplates typescript Advanced

Bull Queue Job Processor

Process background jobs with BullMQ: add jobs, define worker, handle retries.

typescript
import { Queue, Worker, QueueEvents } from "bullmq";

const emailQueue = new Queue("emails", { connection: { host: "localhost", port: 6379 } });

// Add job
await emailQueue.add("welcome", { to: "user@example.com", name: "Alice" }, {
  attempts: 3,
  backoff: { type: "exponential", delay: 5000 },
});

// Worker
const worker = new Worker("emails", async (job) => {
  console.log("Sending email to", job.data.to);
  await sendEmail(job.data);
}, { connection: { host: "localhost", port: 6379 } });

worker.on("failed", (job, err) => console.error(job?.id, err.message));

Prerequisites

  • bullmq >= 5
  • Redis >= 6

Pro Tips

  • → Use a QueueEvents listener to monitor completions in another process.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
typescript
Level
Advanced
Read time
5 min
Published
May 2026
License
Commercial License

Newsletter

New modules every week, directly to your inbox.