Skip to content

Connect to RabbitMQ

View as Markdown
Your servicessend messagesRabbitMQexchangesYour servicesread their own queuesa temporary queue of its ownstreamviewonly readsYour browserthe timelineNew messages only. There is no history.The queue is gone when streamview stops.

You need the streamview program, Node.js, and the address of a RabbitMQ server.

streamview does not read the queues of your services. It makes a temporary queue of its own. Thus your services continue to get all their messages. See How streamview reads without taking messages.

Run this command with the address, the user, and the password of your server:

streamview rabbitmq --url amqp://user:password@localhost:5672

The first time, the command installs the RabbitMQ adapter. This takes some seconds. The browser then opens. Each routing key on each exchange is one lane.

To find the exchanges, streamview uses the management API of RabbitMQ on port 15672. It uses the user and the password from --url. It does not read the exchanges of RabbitMQ itself, which have names that start with amq..

Put the virtual host at the end of the address:

streamview rabbitmq --url amqp://user:password@localhost:5672/my-vhost

For a connection with TLS, start the address with amqps://:

streamview rabbitmq --url amqps://user:password@broker.example.com:5671

Add --exchanges with the names, and a comma between them:

streamview rabbitmq --url amqp://user:password@localhost:5672 --exchanges orders,payments

Connect if the management API is not available

Section titled “Connect if the management API is not available”

If the management API has a different address, give it with --management:

streamview rabbitmq --url amqp://user:password@localhost:5672 --management http://localhost:8080

If there is no management API, do these two steps:

  1. Add --no-management.
  2. Add --exchanges with the names of the exchanges.

For a direct exchange, also add --routing-keys with the routing keys that you want to see. Without the management API, streamview cannot find them.

streamview rabbitmq --url amqp://user:password@localhost:5672 --no-management \
--exchanges orders,payments --routing-keys charge,refund

See the messages that go directly to a queue

Section titled “See the messages that go directly to a queue”

A program can send a message directly to a queue. RabbitMQ calls this the default exchange. streamview cannot connect its queue to the default exchange, thus it does not see these messages.

To see them, use the tracer of RabbitMQ:

  1. On the RabbitMQ server, run rabbitmqctl trace_on.
  2. Start streamview with --trace.
streamview rabbitmq --url amqp://user:password@localhost:5672 --trace

streamview then gets a copy of each message that a program publishes, on all exchanges.

If your messages are CloudEvents, streamview uses their correlationid field.

If your messages are plain JSON, streamview uses the correlation_id property of the message. If your programs do not set this property, add --correlation-field with the name of the field that all messages of one order contain.

streamview rabbitmq --url amqp://user:password@localhost:5672 --correlation-field orderId

Each routing key becomes one lane. If your routing keys contain IDs or regions, there are too many lanes. Use --depth to make a lane from only the first parts of the routing key.

streamview rabbitmq --url amqp://user:password@localhost:5672 --depth 2

With --depth 2, order.created.eu and order.created.us are one lane.