# RabbitMQ recipe

URL: https://briq.cloud/cookbook/rabbitmq

> AMQP message broker with the management UI enabled.

Tags: queue, messaging

Guide:

- [Connect to a database from outside](https://briq.cloud/docs/guides/connect-to-a-database-from-outside.md): A briq's database reachable from psql, a BI tool or an app elsewhere, over TLS, with a normal connection string.

## Run it

MCP:

```ts
briq_run({
  recipe: "rabbitmq",
  params: {
    "version": "4",
    "size": "small",
    "diskGb": 1
  },
  wait: true
})
```

REST:

```bash
curl -X POST https://api.briq.cloud/v1/briqs \
  -H "Authorization: Bearer $BRIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipe": "rabbitmq",
    "params": {
      "version": "4",
      "size": "small",
      "diskGb": 1
    },
    "wait": true
  }'
# → { "briqs": [{ "id": "bq_…", … }], "outputs": { "AMQP_URL": "…" }, … }

# ... when done, for each briq id
curl -X DELETE https://api.briq.cloud/v1/briqs/<id> \
  -H "Authorization: Bearer $BRIQ_API_KEY"
```

## Parameters

| Name | Type | Options | Default | What it does |
| --- | --- | --- | --- | --- |
| `version` | enum | 3.13, 4 | "4" | — |
| `size` | enum | nano, small, medium, large | "small" | — |
| `diskGb` | number | — | 1 | Volume size, in GB |

## Outputs

Returned by `briq_run` once the stack is healthy. Hosts resolve inside your team network; secrets are generated per run.

| Output | Value |
| --- | --- |
| `AMQP_URL` | `amqp://app:<RABBITMQ_PASSWORD>@rabbitmq.<stack>.internal:5672` |
| `RABBITMQ_MANAGEMENT` | `http://rabbitmq.<stack>.internal:15672` |
| `RABBITMQ_USER` | `app` |
| `RABBITMQ_PASSWORD` | `<RABBITMQ_PASSWORD>` |

## What it runs

| Briq | Image | Ports | Size | Volume |
| --- | --- | --- | --- | --- |
| rabbitmq | `rabbitmq:4-management-alpine` | 5672, 15672 | small | 1 GB at /var/lib/rabbitmq |

## When to use it

* Your services speak AMQP (Celery, MassTransit, amqplib, Spring AMQP) and need real acks,
  prefetch and dead-lettering.
* You want the management UI or HTTP API to inspect queues during a test.

## Tips

* **Boot takes 30 to 60 seconds** on `small`; `briq_run` waits for it.
* **Declare exchanges and queues from code**, so tests see what production sees.
* **Inspect queues**: `briq_exec` with `["rabbitmqctl", "list_queues", "name", "messages"]`.
* **Workers outside briq**: `briq_expose` port 5672 with `protocol: "amqp"` gives an `amqps://`
  URL. See [Connect to a database from outside](https://briq.cloud/docs/guides/connect-to-a-database-from-outside).
* **Management UI for a human**: `briq_run({ recipe: "rabbitmq", expose: "private" })`.
* **Long queues**: messages that outgrow memory go to the volume, which starts small; pass `diskGb`
  for more. Set it when the briq is created, and it counts toward your [plan's
  disk](https://briq.cloud/docs/cost#plans).
