# Hanzo MQ — Hanzo AI

> BullMQ-compatible job queue with scheduling, rate limiting, priorities, retries, and dead letter queues.

Background work, done later

[GitHub](https://github.com/hanzoai)

Job queue

emails

waiting

**sync**priority 1

**invoice**priority 2

**resize**priority 2

**digest**priority 2

workers · concurrency

**invoice**attempt 1

**digest**attempt 1

limiter · max per window

completed · failed

**welcome**completed

**resize**completed

QueueEvents

**completed** resize

**completed** welcome

**progress** invoice

**progress** digest

## The queue is data, the workers are yours

emails

- #41**welcome**waitingpriority 1
- #42**invoice**worker aattempt 1
- #43**resize**worker battempt 2
- #44**digest**completedattempt 1
- #45**sync**failed setattempts 3 / 3

worker aworker bemails · held in the store

1. 01 / 06
   
   A cron expression, a delay in milliseconds, or a job that repeats on an interval — timezone aware, and held in the store rather than in a process that might restart.
   
2. 02 / 06
   
   Cap how many jobs a queue may start in a window, and how many a single worker runs at once. The third-party API with a quota stops being the reason your service falls over.
   
3. 03 / 06
   
   A job carries a priority, so the urgent one goes ahead of the backlog. Inside one priority it stays first in, first out, which is what keeps ordinary work from quietly starving.
   
4. 04 / 06
   
   Set attempts and a backoff — fixed, exponential, or a function you write. A worker that dies mid-job loses its lock and the job is handed to another, so work is attempted at least once and can be attempted twice. Write it to be idempotent and that is a property rather than a surprise.
   
5. 05 / 06
   
   QueueEvents streams completed, failed, progress and stalled as they occur, so a job's life is something you observe rather than reconstruct from logs afterwards.
   
6. 06 / 06
   
   A job that runs out of attempts lands in the failed set carrying its error and stack. Read it, fix the cause, retry it. Nothing disappears because it went wrong.
   

## Add a job and walk away

[View on GitHub](https://github.com/hanzoai)

Free tier includes 10K jobs/month. No job size limits.

No broker to run

Library

Scheduling

Cron

With backoff

Retries

Delivery

At-least-once

## Add a job here, run it there

Paste and ship

Paste this into any agent. It reads the skill manifest and calls MQ from there.

Agent prompt

```
Read https://hanzo.ai/skill.md and use Hanzo MQ in my project. Start with: hanzo mq stream list
```

worker.ts

```
import { Queue, Worker } from "@hanzo/mq"

const queue = new Queue("emails", {
  connection: { host: "kv.hanzo.ai", port: 6379 }
})

// Add jobs with options
await queue.add("welcome", { userId: "usr_123" }, {
  priority: 1,
  delay: 5000,
  attempts: 3,
  backoff: { type: "exponential", delay: 1000 },
})

// Process jobs
const worker = new Worker("emails", async (job) => {
  await sendEmail(job.data.userId, "welcome")
}, {
  connection: { host: "kv.hanzo.ai", port: 6379 },
  concurrency: 10,
  limiter: { max: 100, duration: 60_000 },
})
```

## Get MQ

Message queue

[GitHub](https://github.com/hanzoai)[Deploy to Cloud](https://platform.hanzo.ai/deploy)

- License: Apache-2.0
- [hanzoai](https://github.com/hanzoai)
