RabbitMQ

Cloud Agnostic
Open Source

Distributes notifications across gateway instances via RabbitMQ fanout exchanges. Each Notiway instance binds its own queue to the exchange, so every instance receives every notification.

Source code: Notiway.Plugins.Portable.Brokers.RabbitMQ

Compatibility

Pairs withRabbitMQ Buffer
ProductNotiway Notify

Installation

Environment Variables

Required

VariableDescription
Infra__Plugins__Broker__NameSet to RabbitMQ
Infra__Plugins__Broker__VersionPlugin version (e.g., 0.12.0)
Infra__Plugins__Broker__Settings__ConnectionStringRabbitMQ connection string (e.g., amqp://guest:guest@localhost:5672)

Optional

VariableDefaultDescription
Infra__Plugins__Broker__Settings__ExchangeNamenotiway-notificationsName of the exchange used for broadcasting notifications
Infra__Plugins__Broker__Settings__ExchangeTypefanoutExchange type (fanout, direct, topic, headers)
Infra__Plugins__Broker__Settings__DurabletrueWhether the exchange survives broker restarts

Infrastructure

  1. Running RabbitMQ instance — v3.8+ recommended.
  2. The exchange is created automatically by the plugin on startup if it doesn’t exist. No manual setup needed.

Docker Compose

docker-compose.yml
services:
  notiway:
    image: notiway/notify:portable-0.5.0
    ports:
      - "5000:8080"
    environment:
      - Infra__Plugins__Broker__Name=RabbitMQ
      - Infra__Plugins__Broker__Version=0.12.0
      - Infra__Plugins__Broker__Settings__ConnectionString=amqp://guest:guest@rabbitmq:5672

  rabbitmq:
    image: rabbitmq:3-management-alpine
    ports:
      - "5672:5672"
      - "15672:15672"

Usage

Publish notifications to the RabbitMQ exchange from your backend. The message body must be the notification JSON.

var factory = new ConnectionFactory { Uri = new Uri("amqp://guest:guest@localhost:5672") };
using var connection = await factory.CreateConnectionAsync();
using var channel = await connection.CreateChannelAsync();

var body = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(notification));
await channel.BasicPublishAsync(exchange: "notiway-notifications", routingKey: "", body: body);
const amqp = require("amqplib");

const conn = await amqp.connect("amqp://guest:guest@localhost:5672");
const ch = await conn.createChannel();
ch.publish("notiway-notifications", "", Buffer.from(JSON.stringify(notification)));
import pika, json

connection = pika.BlockingConnection(pika.ConnectionParameters("localhost"))
channel = connection.channel()
channel.basic_publish(exchange="notiway-notifications", routing_key="", body=json.dumps(notification))
ConnectionFactory factory = new ConnectionFactory();
factory.setUri("amqp://guest:guest@localhost:5672");

try (Connection connection = factory.newConnection();
     Channel channel = connection.createChannel()) {
    String message = objectMapper.writeValueAsString(notification);
    channel.basicPublish("notiway-notifications", "", null, message.getBytes(StandardCharsets.UTF_8));
}
#include <amqpcpp.h>
#include <amqpcpp/libevent.h>

AMQP::TcpConnection connection(&handler, AMQP::Address("amqp://guest:guest@localhost:5672"));
AMQP::TcpChannel channel(&connection);

std::string message = /* serialize notification as JSON */;
channel.publish("notiway-notifications", "", message);