> ## Documentation Index
> Fetch the complete documentation index at: https://nestcrate.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# nestrs-bullmq

> Enqueue jobs using the BullMQ Redis key layout so Node @nestjs/bullmq workers can consume them.

nestrs `queues-redis` uses LPUSH/BRPOP envelopes. Node `@nestjs/bullmq` workers speak the **BullMQ key layout**. `nestrs-bullmq` is a Redis **producer** that writes jobs those workers can pick up. It does not run a Rust BullMQ worker.

## Install

```toml theme={null}
[dependencies]
nestrs = { version = "1.5.0", features = ["queues"] }
nestrs-bullmq = "1.5.0"
```

The `queues` feature is optional. Use it for in-process nestrs processors; use this crate when the consumer is BullMQ (often Node).

## Enqueue a job

```rust theme={null}
use nestrs_bullmq::BullMqProducer;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), nestrs_bullmq::BullMqError> {
    let producer = BullMqProducer::new("redis://127.0.0.1/", "email")?
        .with_prefix("bull"); // default

    let id = producer
        .add("welcome", &json!({ "to": "ada@example.com" }))
        .await?;
    println!("enqueued job {id}");
    Ok(())
}
```

`add` INCR's `{prefix}:{queue}:id`, HSETs the job hash, then LPUSHes the id onto `{prefix}:{queue}:wait`.

## Key layout

Prefix defaults to `bull` (BullMQ):

| Key | Role |
| - | - |
| `{prefix}:{queue}:id` | INCR job id |
| `{prefix}:{queue}:{id}` | Hash: `name`, `data` (JSON string), `opts`, `timestamp` |
| `{prefix}:{queue}:wait` | LPUSH job id |

Override the prefix when the Node app uses a custom `prefix` in `BullModule.forRoot`.

## Compared with queues-redis

| | `queues` / `queues-redis` | `nestrs-bullmq` |
| - | - | - |
| Wire format | nestrs LPUSH/BRPOP envelope | BullMQ hashes + wait list |
| Consumer | `#[queue_processor("NAME")]` in Rust | BullMQ / `@nestjs/bullmq` (often Node) |
| Multi-instance nestrs | `queues-redis` | Not a substitute — different protocol |

See [QueuesModule](/ecosystem/scheduling) for the in-process / `queues-redis` path.
