November 8, 2025•2 min read

Run RabbitMQ with the management plugin enabled:
docker run -d \
--name rabbitmq \
-p 5672:5672 \
-p 15672:15672 \
rabbitmq:managementThe connexion string is amqp://localhost:5672
You can connect to your instance using RabbitGUI at http://localhost:15672 (guest/guest)

Create a docker-compose.yml file with custom credentials and persistent storage:
version: '3'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
ports:
- "5672:5672"
- "15672:15672"
environment:
RABBITMQ_DEFAULT_USER: user
RABBITMQ_DEFAULT_PASS: password
volumes:
- rabbitmq_data:/var/lib/rabbitmq
volumes:
rabbitmq_data:The connexion string is amqp://user:password@localhost:5672
You can connect to your instance using RabbitGUI at http://localhost:15672 (user/password)
Add the amqplib package to your project:
npm install amqplibYou can publish directly to a queue using the sendToQueue method:
import amqp from "amqplib";
const connection = await amqp.connect("amqp://localhost:5672");
const channel = await connection.createChannel();
await channel.assertQueue("my_queue");
channel.sendToQueue("my_queue", Buffer.from("Hello RabbitGUI!"));
await channel.close();
await connection.close();Your consumer can listen to messages from a queue using the consume method:
import amqp from "amqplib";
const connection = await amqp.connect("amqp://localhost:5672");
const channel = await connection.createChannel();
await channel.assertQueue("my_queue");
channel.consume("my_queue", (msg) => {
console.log("Message", msg.content.toString());
}, { noAck: true });A direct exchange routes messages to queues based on exact routing key matches:
await channel.assertExchange("my_exchange", "direct");
await channel.assertQueue("my_queue");
await channel.bindQueue("my_queue", "my_exchange", "my.routing.key");
channel.publish("my_exchange", "my.routing.key", Buffer.from("Hello RabbitGUI!"));
channel.consume("my_queue", (msg) => {
console.log("Message", msg.content.toString());
});A fanout exchange broadcasts messages to all bound queues, ignoring routing keys:
await channel.assertExchange("my_exchange", "fanout");
await channel.assertQueue("my_queue");
await channel.bindQueue("my_queue", "my_exchange", "");
channel.publish("my_exchange", "", Buffer.from("Hello RabbitGUI!"));
channel.consume("my_queue", (msg) => {
console.log("Message", msg.content.toString());
});A topic exchange routes messages based on wildcard pattern matching (* for one word, # for zero or more words):
await channel.assertExchange("my_exchange", "topic");
await channel.assertQueue("my_queue");
await channel.bindQueue("my_queue", "my_exchange", "*.routing.*");
channel.publish("my_exchange", "my.routing.key", Buffer.from("Hello RabbitGUI!"));
channel.consume("my_queue", (msg) => {
console.log("Message", msg.content.toString());
});RabbitMQ will dequeue messages as soon as they’ve been sent down the wire.
channel.consume("my_queue", (msg) => {
//...
}, { noAck: true });Manually acknowledge messages after processing to ensure they are removed from the queue:
channel.consume("my_queue", (msg) => {
//...
channel.ack(msg)
});Reject a message and put it back in the queue for reprocessing:
channel.consume("my_queue", (msg) => {
//...
channel.nack(msg)
});Reject a message and discard it (sends to dead letter queue if configured):
channel.consume("my_queue", (msg) => {
//...
channel.nack(msg, false, false)
});Configure a queue with a dead letter exchange to catch rejected or expired messages:
import amqp from "amqplib";
const connection = await amqp.connect("amqp://localhost:5672");
const channel = await connection.createChannel();
// Create the dead letter exchange and queue
await channel.assertExchange("dlx_exchange", "direct");
await channel.assertQueue("dead_letter_queue");
await channel.bindQueue("dead_letter_queue", "dlx_exchange", "");
// Create main queue with dead letter configuration
await channel.assertQueue("my_queue", {
deadLetterExchange: "dlx_exchange",
deadLetterRoutingKey: ""
});
How to log into your CloudAMQP RabbitMQ instanceUse RabbitGUI to connect to your CloudAMQP instance and manage your dead letter queues with ease
How security is built into RabbitGUIRabbitGUI was built with security as a top priority for its users, and here is how it was done!
A better RabbitMQ UIA geat experience is made out of many small details, have a look at all the features we packed into RabbitGUI to make your life easierDebug, monitor, and manage RabbitMQ with a modern developer interface.
Try now