Skip to content

Message brokers and queues ​

A message broker is a container like any other, but Viaduct recognises it by its technology and gives it a level of its own. Inside a broker you describe its channels: Kafka topics, RabbitMQ queues and exchanges, and the like, each with the schema of its messages.

The technologies that count as a broker are Apache Kafka, RabbitMQ, Amazon SQS, Redis Streams, NATS and MQTT.

A Kafka broker, a service that writes to it, and one of its topics.

Add the broker ​

On the Containers level of a system:

  • Kafka. Press Add block and choose the Kafka preset. It adds a container named "Kafka" with the Apache Kafka technology.
  • RabbitMQ and the others. There is no preset. Add an Empty block (or double-click the canvas), open its panel and choose RabbitMQ in Technology. Name it and save.

What makes a container a broker is its first technology. If a container has several, put the broker's first.

Connect services to it ​

Draw a connection from a service to the broker if the service publishes messages, and from the broker to the service if it reads them. Click the line: on a connection to or from a broker the panel has a Channel role field, Produce or Consume, filled in from the direction of the arrow. Change it if the arrow points the other way for another reason.

Add channels ​

  1. Click the magnifier on the broker's block. The level that opens is called Topics.
  2. Press Add block. The menu offers Empty channel ("Topic, queue or exchange on this broker") and three presets: orders.created and orders.updated (Kafka topics with an Avro schema) and jobs (a queue with a JSON Schema).
  3. The channel appears as a block with its protocol and its kind: Topic for Kafka, NATS and MQTT, Exchange for RabbitMQ (amqp), Queue for Amazon SQS, Stream for Redis Streams.

For RabbitMQ, add one channel per exchange or queue that services agree on, and name it the way RabbitMQ does, for example payments.events or invoices.send. The block is labelled Exchange whatever you name it; say in the description which it is and how it is bound.

A double click on the canvas does not add anything here: channels come only from the menu.

The channel's panel ​

Click a channel to open its panel.

FieldWhat to fill in
NameAt the top of the panel: the topic, queue or exchange name as the broker knows it, for example orders.created.
DescriptionOne line on what the messages say.
Protocolkafka, amqp (RabbitMQ), sqs, nats, redis-stream or mqtt. A new channel takes the protocol of its broker.
Schema formatHow the messages are described: avro, json-schema, protobuf or cloudevents.
CompatibilityThe schema registry rule for changing the schema: backward, forward, full, none, or Not set.
Key schemaThe schema of the message key.
Value schemaThe schema of the message body.
Headers schemaThe schema of the headers.

Each schema row opens an editor for the chosen format. A schema is applied only when it parses; a broken one is marked on its row. The value schema's editor also holds Example messages: press Add example and fill in what a real message looks like, its key, value and headers.

Tags & group work as for other elements. Press Save.

Back on the Containers level, the broker's block shows a badge with the number of its channels ("Channel contracts — 3 topics"). It opens the list of the broker's channels with their contracts, and each can be exported.

Channels can also be shown inside a documentation page: see Project documentation.