RabbitMQ
A single-node RabbitMQ container with the management plugin enabled. Defaults to the image's own guest/guest credentials.
Default image: rabbitmq:managementExposed ports: 5672 (AMQP), 15672 (management HTTP API) Wait strategy: log message ".*Server startup complete.*"
| Member | Returns |
|---|---|
RabbitMQContainer.start(image?) | Promise<RabbitMQContainer> — boots the container |
.withUsername(name) | this — overrides RABBITMQ_DEFAULT_USER (default guest) |
.withPassword(pw) | this — overrides RABBITMQ_DEFAULT_PASS (default guest) |
.username / .password | The configured credentials |
.amqpUrl | An amqp://user:pass@host:port connection URL |
.managementUrl | The management HTTP API's base URL |
Example
ts
import { RabbitMQContainer } from "rightsize/modules";
import amqplib from "amqplib";
await using rabbit = await RabbitMQContainer.start();
const conn = await amqplib.connect(rabbit.amqpUrl);
const channel = await conn.createChannel();
// RabbitMQ 4.x rejects transient non-exclusive queues — declare durable or exclusive.
await channel.assertQueue("q", { durable: true });
await channel.sendToQueue("q", Buffer.from("hello"));
await conn.close();Backend notes
- No-arg construction floats to
rabbitmq:management, not plainrabbitmq:latest. This module depends on the management plugin, and plainlatestdoesn't ship it — verified againstrabbitmq:4-management-alpine; themanagementtag carries no-alpinesuffix, so it floats onto Debian rather than Alpine the same way this library's otherlatestdefaults do. - Compatibility check: the constructor only accepts images whose repository is
rabbitmq(registry host, tag, and digest stripped). A different repository throwsIncompatibleImageErrorbefore any backend call; override withDockerImageName.parse(image).asCompatibleSubstituteFor("rabbitmq")for a verified compatible fork or mirror. - RabbitMQ 4.x rejects declaring a transient (non-durable), non-exclusive queue — a behavior change from 3.x. Declare durable or exclusive queues, as in the example above; a transient shared queue now errors at declare time, independent of which backend you're running on.