DEV Community

Cover image for The simplest Message Queue using Redis
Sibelius Seraphini for Woovi

Posted on

6

The simplest Message Queue using Redis

At Woovi we focus on shipping production code with the simplest architecture, this helps us scale easier and have a simple DevOps approach.

We also wrote about all the use cases of Redis at Woovi. And we are going to cover how to implement it

BullMQ

BullMQ is a fast and robust background job processing library for Redis.

It uses Redis to create a queue of messages that will be processed in the background by workers.

You can achieve the same results using other more complex message brokers like RabbitMQ and Kafka.

For us, BullMQ has provided the best cost-benefit until now.

Node Implementation

You need to understand only two concepts to get up and running with BullMQ: Queue and Worker.

A Queue creates a queue on Redis, where your application services can add messages to it or events.

A Worker is a process that will process each message from a specific Queue



import { Queue } from "bullmq";

const queue = new Queue("Payment");

await queue.add("payment_received", {
payment,
});

Enter fullscreen mode Exit fullscreen mode


import { Worker } from 'bullmq';

const worker = new Worker('Payment', async job => {
if (job.name === 'payment_received') {
await processPayment(job.data);
}
}, { concurrency: 100 });

Enter fullscreen mode Exit fullscreen mode




BullMQ Architecture

BullMQ Architecture

BullMQ lets you emit events to any Queue from any server or worker and also scales your workers as your message grows.

Event Driven Benefits

When adopting an event-driven architecture you can easily decouple your code.
Decoupled Code: The code that emits the event does not need to know about the code or service that will process the event.
Fault-Tolerant: You can also add retries when processing a message, making your system more fault-tolerant.
Rate Limit: You can control the rate limit of your processing, read more about it here Control Rate Limit using Queues

In Conclusion

If you are looking for a message queue or distributed processing job, give BullMQ a try.
If you are already using Redis, adding BullMQ to your stack will be easy.
Move to more complex tools like RabbitMQ and Kafka when needed, if needed.


Woovi is an innovative startup revolutionizing the payment landscape. With Woovi, shoppers can enjoy the freedom to pay however they prefer. Our cutting-edge platform provides instant payment solutions, empowering merchants to accept orders and enhance their customer experience seamlessly.

If you're interested in joining our team, we're hiring! Check out our job openings at Woovi Careers.

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay