<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mohamed Bouzraa on Medium]]></title>
        <description><![CDATA[Stories by Mohamed Bouzraa on Medium]]></description>
        <link>https://medium.com/@mohamedbouzraa04?source=rss-71afa0141ca7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_GyVmltqBaIz3CYp</url>
            <title>Stories by Mohamed Bouzraa on Medium</title>
            <link>https://medium.com/@mohamedbouzraa04?source=rss-71afa0141ca7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 03:33:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohamedbouzraa04/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ Introduction to BullMQ: Powerful Queueing for Node.js]]></title>
            <link>https://medium.com/@mohamedbouzraa04/introduction-to-bullmq-powerful-queueing-for-node-js-1c2af1bf0534?source=rss-71afa0141ca7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c2af1bf0534</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[job-queue]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[bullmq]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Mohamed Bouzraa]]></dc:creator>
            <pubDate>Thu, 29 May 2025 10:53:30 GMT</pubDate>
            <atom:updated>2025-05-29T10:55:20.665Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Efficient background job handling with Redis and BullMQ</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GghCO8zg3YzZWuWoQ_iXGA.png" /><figcaption><strong>BullMQ</strong></figcaption></figure><p>🚀 As developers, we often encounter the need to perform background jobs — whether it’s sending emails, processing images, or syncing data with external APIs. In Node.js, one of the most powerful tools for managing job queues is <strong>BullMQ</strong>.</p><p>In this post, I’ll introduce BullMQ, how it works, and how you can get started with it in a Node.js project. By the end, you’ll have a working example and visual dashboard to monitor everything in real-time.</p><h3>💡 What is BullMQ?</h3><p><strong>BullMQ</strong> is a modern Node.js library for handling <strong>jobs and queues</strong> backed by <strong>Redis</strong>. It’s the successor to the popular <a href="https://github.com/OptimalBits/bull">Bull</a> library, with a redesigned architecture that emphasizes modularity, performance, and TypeScript support.</p><h3>🧰 Use Cases</h3><ul><li>Email and notification queues</li><li>Image or video processing pipelines</li><li>Scheduled and delayed tasks</li><li>Rate-limited background jobs</li><li>Web scraping or data syncing</li></ul><h3>⚙️ Installation</h3><p>Let’s get BullMQ running in a few steps.<br>1. Install BullMQ</p><pre>npm install bullmq</pre><h3>2. Start Redis (Using Docker)</h3><pre>docker run -p 6379:6379 redis</pre><blockquote><em>Make sure Redis is running. You can also install it directly or use a managed service.</em></blockquote><h3>🔨 Getting Started: Minimal Example</h3><p>Let’s build a simple email queue.</p><h3>🧾 1. Producer (Add Jobs)</h3><pre>const { Queue } = require(&#39;bullmq&#39;);<br>const connection = { host: &#39;localhost&#39;, port: 6379 };<br><br>const emailQueue = new Queue(&#39;emailQueue&#39;, { connection });<br><br>async function addJob() {<br>  await emailQueue.add(&#39;sendEmail&#39;, {<br>    to: &#39;user@example.com&#39;,<br>    subject: &#39;Welcome!&#39;,<br>    body: &#39;Thanks for signing up.&#39;<br>  });<br>}<br><br>addJob();</pre><h3>🛠️ 2. Worker (Process Jobs)</h3><pre>const { Worker } = require(&#39;bullmq&#39;);<br>const connection = { host: &#39;localhost&#39;, port: 6379 };<br><br>const worker = new Worker(&#39;emailQueue&#39;, async job =&gt; {<br>  console.log(`Sending email to ${job.data.to}`);<br>  // simulate sending email<br>}, { connection });</pre><h3>✅ Output</h3><pre>Sending email to user@example.com</pre><h3>📊 Bonus: BullMQ Dashboard</h3><p>To visually monitor your queues, you can use Bull Board.</p><h3>Install it:</h3><pre>npm install @bull-board/express express</pre><h3><strong>Setup:</strong></h3><pre>const express = require(&#39;express&#39;);<br>const { createBullBoard } = require(&#39;@bull-board/api&#39;);<br>const { BullMQAdapter } = require(&#39;@bull-board/api/bullMQAdapter&#39;);<br>const { ExpressAdapter } = require(&#39;@bull-board/express&#39;);<br>const { Queue } = require(&#39;bullmq&#39;);<br><br>const app = express();<br>const serverAdapter = new ExpressAdapter();<br>serverAdapter.setBasePath(&#39;/admin/queues&#39;);<br><br>const emailQueue = new Queue(&#39;emailQueue&#39;);<br><br>createBullBoard({<br>  queues: [new BullMQAdapter(emailQueue)],<br>  serverAdapter,<br>});<br><br>app.use(&#39;/admin/queues&#39;, serverAdapter.getRouter());<br>app.listen(3000, () =&gt; console.log(&#39;Dashboard on http://localhost:3000/admin/queues&#39;));</pre><p>Now visit http://localhost:3000/admin/queues and view your queue in action 🎉</p><h3>🌟 BullMQ Features</h3><ul><li><strong>🕒 Delayed Jobs:</strong> Run jobs after a set delay</li><li>🔁 Repeatable Jobs: Run jobs on a schedule (like CRON)</li><li>🔄 Retries &amp; Backoff: Auto-retry failed jobs with exponential backoff</li><li>📦 Job Priority: Control which jobs run first</li><li>⚡ Concurrency Control: Limit how many jobs a worker processes at once</li><li>📢 Event Listeners: Listen for events like completed, failed, etc.</li></ul><h3>📚 Resources</h3><ul><li><a href="https://docs.bullmq.io/readme-1">🔗 BullMQ Documentation</a></li><li>💻 <a href="https://github.com/taskforcesh/bullmq">BullMQ GitHub</a></li><li><a href="https://hub.docker.com/_/redis">🛠️ Redis Docker Image</a></li><li><a href="https://www.npmjs.com/package/@bull-board/ui">📊 Bull Board UI</a></li></ul><h3>🧠 Final Thoughts</h3><p>If your application requires background processing or scheduled jobs, <strong>BullMQ</strong> is a rock-solid choice. It’s scalable, developer-friendly, and backed by Redis — which means you get performance and reliability out of the box.</p><p>I hope this post gave you a clear and practical start with BullMQ. In upcoming articles, I’ll explore advanced topics like:</p><ul><li>Job dependencies</li><li>Rate limiting</li><li>Using BullMQ with TypeScript</li><li>Horizontal scaling and clustering</li></ul><h3>📣 Stay Connected</h3><p>If you found this helpful:</p><p>✅ Clap this post<br>📌 Follow me on Medium for more Node.js, backend, and DevOps tutorials<br>💬 Feel free to leave a comment or ask a question</p><h3>👨‍💻 About the Author</h3><p>I’m Mohamed — a full-stack developer passionate about building scalable backend systems and teaching modern web tools.<br>Find me on <a href="https://github.com/medo2203">GitHub </a>| <a href="https://www.linkedin.com/in/mohamed-bouzraa/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c2af1bf0534" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>