MQOx is a lightweight, flexible message queuing system powered by Redis. It supports delayed jobs, retries, priority-based job scheduling, worker processing, and features a Dead Letter Queue (DLQ) for robust fault tolerance.
| Model | QoS Level | Persistence | Delivery Guarantee | Ideal For |
|---|---|---|---|---|
| Queue | QoS 1 | β Yes | Guaranteed (with DLQ) | Background jobs, task runners |
| Queue (Priority) | QoS 1 | β Yes | Guaranteed (priority order) | Task scheduling, notifications, SLA jobs |
| Pub/Sub | QoS 0 | β No | Best effort (fire & forget) | Real-time notifications |
| Pub/Sub | QoS 1 | β Yes | At-Least-Once Delivery | Financial transactions, critical events |
A message queue is a system that lets applications handle tasks asynchronously - meaning jobs are added to a queue and processed later by background workers instead of immediately. This keeps your app fast, scalable, and fault-tolerant.
MQOx uses Redis to manage these queues efficiently. It lets you:
- Enqueue jobs
- Process them using workers
- Automatically move failed jobs to a Dead Letter Queue (DLQ)
MQOx helps you build reliable background job systems for tasks like sending emails, generating reports, or handling any heavy processing all without blocking your main application.
| Feature | Description |
|---|---|
| Job Enqueuing | Push jobs with optional delays and retry settings |
| Worker Consumption | Workers continuously listen and process jobs |
| Retry Mechanism | Automatically retries failed jobs |
| Dead Letter Queue | Moves permanently failed jobs to a DLQ |
| Scalable Architecture | Multiple workers can consume from the same queue |
~/Desktop/MQOx$ mqox-dashboard
MQOx Dashboard is starting...
Connected to Redis at redis://localhost:6379
MQOx Dashboard: http://localhost:3000const { Queue, Employee } = require("@udthedeveloper/mqox");
const queue = new Queue("emailQueue");
const worker = new Employee("emailQueue");
worker.work(async (job) => {
console.log("Processing job:", job);
});const { Queue } = require("@udthedeveloper/mqox");
async function main() {
const queue = new Queue({ queueName: "emailQueue", priority: true });
await queue.connect();
await queue.enqueue(
"sendEmail",
{ to: "vip@domain.com" },
{ priorityLevel: 1 }
);
await queue.enqueue(
"sendEmail",
{ to: "user@domain.com" },
{ priorityLevel: 3 }
);
await queue.enqueue(
"sendEmail",
{ to: "subscriber@domain.com" },
{ priorityLevel: 5 }
);
console.log("β
Emails enqueued by priority");
}
main();const { Employee } = require("@udthedeveloper/mqox");
async function main() {
const worker = new Employee("emailQueue", { priority: true });
await worker.work(async (job) => {
console.log(`π© Sending email to ${job.payload.to}`);
await new Promise((r) => setTimeout(r, 1000));
console.log(`β
Email sent to ${job.payload.to}`);
});
}
main();const { PubSub0 } = require("@udthedeveloper/mqox");
const pubsub = new PubSub0("notifications");
pubsub.subscribe((msg) => console.log("Received:", msg));
pubsub.publish({ text: "Hello world!" });const { PubSub1 } = require("@udthedeveloper/mqox");
const pubsub = new PubSub1("order-stream", "order-group", "worker-1");
async function main() {
await pubsub.connect();
await pubsub.publish({ orderId: 101, status: "CREATED" });
pubsub.subscribe(async (message) => {
console.log("Received QoS1 message:", message);
});
}
main();MQOx
β
βββ src
β βββ demo
β β βββ demoJobEmployee.ts # Worker demo
β β βββ demoJobProducer.ts # Queue demo producer
β β
β βββ pubsub
β β βββ qos-0.ts # Pub/Sub QoS 0
β β βββ qos-1.ts # Pub/Sub QoS 1
β β
β βββ types
β β βββ employee.type.ts
β β βββ enqueue.type.ts
β β βββ job.type.ts
β β
β βββ employee.ts
β βββ queue.ts
β βββ redisClient.ts
β βββ index.ts
β
βββ public/assets
β βββ example.jpeg
β βββ Flow.jpg
β βββ logo.jpeg
β
βββ .env
βββ package.json
βββ tsconfig.json
βββ README.md
git clone https://github.com/udaykumar-dhokia/MQOx.git
cd MQOxnpm installCreate a .env file in the project root:
REDIS_URL=redis://localhost:6379Make sure Redis is running locally or update the URL accordingly.
npm run buildThis will start listening for jobs and processing them.
npm run demo:employeeIn a new terminal:
npm run demo:producer- Jobs will be added to the queue.
- Worker consumes them.
- If a job fails and retry attempts are exhausted, it's moved to the Dead Letter Queue.
ββββββββββββββββββ
β Producer β
β (enqueue job) β
βββββββββ¬βββββββββ
βΌ
βββββββββββββββββββββββββ
β Redis Queue (FIFO) β
βββββββββ¬ββββββββββββββββ
βΌ
βββββββββββββββββββββββββ
β Employee (Worker) β
β Processes the Job β
βββββββββ¬ββββββββ¬ββββββββ
βSuccessβFailure
β βΌ
β RetryCount > 0?
β β
β ββ YES β Requeue
β ββ NO β Dead Letter Queue
βΌ
βββββββββββββββββββββββββ
βDead Letter Queue (DLQ)β
βββββββββββββββββββββββββ
| Command | Description |
|---|---|
npm install |
Install dependencies |
npm run build |
Compile TypeScript |
npm run demo:employee |
Run worker demo |
npm run demo:producer |
Run producer demo |
You can define these scripts in your package.json like:
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"demo:employee": "ts-node src/demo/demoJobEmployee.ts",
"demo:producer": "ts-node src/demo/demoJobProducer.ts"
}Pull requests and feature suggestions are welcome!
β If this project is useful to you, please give it a star to show your support!
