Bsa.MQ — брокер сообщений, совместимый с RabbitMQBsa.MQ — a RabbitMQ-compatible message broker
Брокер сообщений на C#, совместимый с RabbitMQ по протоколу AMQP 0-9-1: приложения и штатные клиенты RabbitMQ подключаются к нему без изменений. Management API в формате RabbitMQ, веб-интерфейс, метрики Prometheus. Работает отдельным сервером, в Docker или встраивается прямо в .NET-приложение.
A message broker in C#, compatible with RabbitMQ over AMQP 0-9-1: applications and standard RabbitMQ clients connect to it unchanged. A RabbitMQ-format management API, a web UI, Prometheus metrics. Runs as a standalone server, in Docker, or embedded right into a .NET application.
ВозможностиFeatures
Совместим с RabbitMQRabbitMQ-compatible
AMQP 0-9-1 полностью и расширения RabbitMQ: штатные клиенты (RabbitMQ.Client, pika, amqplib, Java, Spring AMQP, MassTransit, EasyNetQ) работают без изменений.
Full AMQP 0-9-1 plus RabbitMQ extensions: standard clients (RabbitMQ.Client, pika, amqplib, Java, Spring AMQP, MassTransit, EasyNetQ) work unchanged.
Management API и веб-интерфейсManagement API and web UI
HTTP API в формате RabbitMQ, веб-интерфейс со статистикой, метрики Prometheus с именами rabbitmq_*, health checks.
RabbitMQ-format HTTP API, a web UI with statistics, Prometheus metrics named rabbitmq_*, health checks.
Надёжное хранениеDurable storage
Журнал из сегментов с CRC32, group commit и fsync до подтверждения издателю, компакция. Очереди больше ОЗУ вытесняются на диск.
A segmented journal with CRC32, group commit and fsync before the publisher confirm, compaction. Queues larger than RAM are paged to disk.
Встраивается в приложениеEmbeddable
Ядро Bsa.MQ.Core — обычная библиотека без ASP.NET: брокер поднимается одной строкой и доступен по сети и in-process.
The Bsa.MQ.Core core is a plain library without ASP.NET: start a broker in one line, reachable over the network and in-process.
Shovel и FederationShovel and Federation
Перекачка сообщений между брокерами в форматах параметров RabbitMQ — в том числе из RabbitMQ в Bsa.MQ при миграции.
Moving messages between brokers using RabbitMQ parameter formats — including from RabbitMQ to Bsa.MQ during migration.
Пакеты для российских ОСPackages for Russian Linux
deb, rpm, отдельный rpm для ALT Linux, tar.gz и Docker. Astra Linux, РЕД ОС, ALT — без установки .NET.
deb, rpm, a separate rpm for ALT Linux, tar.gz and Docker. Astra Linux, RED OS, ALT — no .NET installation required.
ЗагрузкиDownloads
Сборки для Linux x86_64. Порты по умолчанию: AMQP — 25672, веб-интерфейс и management API — 15672 (стандартные порты RabbitMQ 5672 и 15672 меняются в настройках).
Builds for Linux x86_64. Default ports: AMQP — 25672, web UI and management API — 15672 (switch to the standard RabbitMQ port 5672 in the settings).
| ВерсияVersion | ФорматFormat | ФайлFile | ОписаниеDescription | РазмерSize | ДатаDate |
|---|---|---|---|---|---|
| 8.0.1 | DEB | bsamq_8.0.1-1_amd64.deb | Debian / Ubuntu / Astra LinuxDebian / Ubuntu / Astra Linux | 30.2 MB | 2026-11-01 |
| 8.0.1 | RPM | bsamq-8.0.1-1.x86_64.rpm | RHEL / Rocky / Alma / Fedora / РЕД ОСRHEL / Rocky / Alma / Fedora / RED OS | 41.9 MB | 2026-11-01 |
| 8.0.1 | RPM | bsamq-8.0.1-alt1.x86_64.rpm | ALT LinuxALT Linux | 29.5 MB | 2026-11-01 |
| 8.0.1 | TAR.GZ | bsamq-8.0.1-linux-x64.tar.gz | Любой Linux x64 (без менеджера пакетов)Any Linux x64 (no package manager) | 42.2 MB | 2026-11-01 |
| 8.0.1 | DOCKER | bsamq-8.0.1-docker-x64.tar | Образ Docker для docker loadDocker image for docker load | 88.8 MB | 2026-11-01 |
| 8.0.1 | SHA256 | SHA256SUMS-8.0.1.txt | Контрольные суммы файловFile checksums | 1 KB | 2026-11-01 |
Установка на LinuxInstalling on Linux
Пакеты self-contained: .NET на сервере не нужен. Ставят службу systemd bsamq и сразу её запускают.
The packages are self-contained: no .NET is needed on the server. They install the bsamq systemd service and start it.
sudo apt install ./bsamq_8.0.1-1_amd64.deb # Debian / Ubuntu / Astra Linux
sudo dnf install ./bsamq-8.0.1-1.x86_64.rpm # RHEL / Rocky / Alma / РЕД ОС
sudo apt-get install ./bsamq-8.0.1-alt1.x86_64.rpm # ALT Linux
systemctl status bsamq
journalctl -u bsamq -f
bsamqctl statusГде что лежитWhere files live
| ПутьPath | ЧтоWhat |
|---|---|
/opt/bsamq | Программа (self-contained: .NET на сервере не нужен)Application (self-contained: no .NET needed on the server) |
/usr/bin/bsamqctl | Утилита управления через management APIManagement CLI over the management API |
/etc/bsamq/bsamq.json | Настройки; при обновлении пакета не перезаписываютсяSettings; not overwritten on package upgrade |
/etc/default/bsamq, /etc/sysconfig/bsamq | Переменные окружения BsaMq__*, Management__* (deb / rpm)Environment variables BsaMq__*, Management__* (deb / rpm) |
/var/lib/bsamq | Данные: definitions, журнал сообщенийData: definitions, message journal |
bsamq.service | Служба systemd от пользователя bsamq, автозапуск включёнsystemd service running as user bsamq, enabled at boot |
- Обновление — установите новый пакет поверх: настройки и данные сохраняются, служба перезапускается.Upgrade — install the new package over the old one: settings and data are kept, the service restarts.
apt remove bsamqоставляет данные и настройки;apt purge bsamqудаляет всё, включая/var/lib/bsamqи пользователя.apt remove bsamqkeeps data and settings;apt purge bsamqremoves everything, including/var/lib/bsamqand the user.- После правки
bsamq.json:sudo systemctl restart bsamq.After editingbsamq.json:sudo systemctl restart bsamq.
Как и в RabbitMQ, пользователь guest/guest входит только с localhost. Для удалённого доступа создайте своего пользователя и закройте порты 25672 и 15672 межсетевым экраном от лишних сетей.
As in RabbitMQ, guest/guest can only log in from localhost. For remote access create your own user, and restrict ports 25672 and 15672 with a firewall.
bsamqctl add_user admin 'S3cret' administrator
bsamqctl set_permissions admin '.*' '.*' '.*' /Архив tar.gz для любого Linuxtar.gz archive for any Linux
Архив содержит те же файлы, что и пакеты (opt, etc, usr). Распакуйте его в корень и создайте пользователя службы:
The archive holds the same files as the packages (opt, etc, usr). Unpack it to the root and create the service user:
sudo tar -C / -xzf bsamq-8.0.1-linux-x64.tar.gz
sudo groupadd --system bsamq
sudo useradd --system --gid bsamq --home-dir /var/lib/bsamq --no-create-home --shell /usr/sbin/nologin bsamq
sudo mkdir -p /var/lib/bsamq /var/log/bsamq && sudo chown bsamq:bsamq /var/lib/bsamq /var/log/bsamq
sudo ln -sf /opt/bsamq/bsamqctl /usr/bin/bsamqctl
sudo systemctl daemon-reload && sudo systemctl enable --now bsamqDockerDocker
Образ поставляется архивом — его можно загрузить на сервер без доступа к реестру. Пользователь по умолчанию создаётся только при первом запуске на пустом томе.
The image ships as an archive, so it can be loaded on a server without registry access. The default user is created only on the first start with an empty volume.
docker load -i bsamq-8.0.1-docker-x64.tar
docker run -d --name bsamq \
-p 25672:25672 -p 15672:15672 \
-v bsamq-data:/var/lib/bsamq \
-e BsaMq__DefaultUser=admin -e BsaMq__DefaultPassword=change-me \
bsamq:8.0.1- Порты: 25672 — AMQP, 25671 — AMQPS (если задан сертификат), 15672 — веб-интерфейс, API и
/metrics.Ports: 25672 — AMQP, 25671 — AMQPS (when a certificate is set), 15672 — web UI, API and/metrics. - Любая настройка задаётся переменной
BsaMq__<Параметр>/Management__<Параметр>или файлом/etc/bsamq/bsamq.json.Any setting can be passed asBsaMq__<Setting>/Management__<Setting>or via/etc/bsamq/bsamq.json. - В образе
guestразрешён не только с localhost — как в официальном образе RabbitMQ. Задайте свой логин и пароль.In the imageguestis allowed from any host, as in the official RabbitMQ image. Set your own login and password.
Проверка файловVerifying downloads
Контрольные суммы SHA-256 всех файлов релиза лежат рядом с ними:
SHA-256 checksums of all release files are published next to them:
sha256sum -c --ignore-missing SHA256SUMS-8.0.1.txtПодключение клиентовConnecting clients
Используйте любой клиент RabbitMQ; меняется только адрес. Веб-интерфейс — http://<сервер>:15672, Prometheus — /metrics.
Use any RabbitMQ client; only the address changes. Web UI: http://<server>:15672, Prometheus: /metrics.
// the standard RabbitMQ.Client works unchanged — only the port differs
var factory = new ConnectionFactory { Uri = new Uri("amqp://guest:guest@localhost:25672") };
using var connection = factory.CreateConnection();
using var channel = connection.CreateModel();
channel.QueueDeclare("hello", durable: true, exclusive: false, autoDelete: false);
channel.BasicPublish("", "hello", null, Encoding.UTF8.GetBytes("Hello, Bsa.MQ"));Проверено клиентами RabbitMQ.Client 6.8 (.NET), pika (Python), amqplib (Node.js). Для микросервисов на .NET подойдёт Bsa.Msa.
Tested with RabbitMQ.Client 6.8 (.NET), pika (Python) and amqplib (Node.js). For .NET microservices see Bsa.Msa.
НастройкиConfiguration
Секции BsaMq и Management файла bsamq.json; любой параметр перекрывается переменной окружения, например BsaMq__Port=5672 или Management__Url=http://0.0.0.0:15672.
The BsaMq and Management sections of bsamq.json; any setting can be overridden by an environment variable, e.g. BsaMq__Port=5672 or Management__Url=http://0.0.0.0:15672.
{
"Management": {
"Enabled": true,
"Url": "http://0.0.0.0:15672"
},
"BsaMq": {
"Host": "0.0.0.0",
"Port": 25672,
"DataDirectory": "/var/lib/bsamq",
"Fsync": "Always",
"DefaultUser": "guest",
"DefaultPassword": "guest",
"DefaultVHost": "/",
"LoopbackUsers": [ "guest" ],
"Heartbeat": 60,
"ConsumerTimeoutMs": 1800000,
"MemoryHighWatermarkBytes": 0
}
}Встраивание в приложениеEmbedding into an application
Брокер можно запустить внутри своего процесса: он доступен и по сети, и через in-process API — без сети и сериализации.
The broker can run inside your own process: it is reachable both over the network and through the in-process API — no network and no serialization.
await using var broker = new BsaMqBroker(new BsaMqOptions
{
Port = 25672, // or EnableAmqpListener = false — in-process only
DataDirectory = "mq-data" // null — everything in memory
});
await broker.StartAsync();
broker.DeclareExchange("/", "events", "topic");
var q = broker.DeclareQueue("/", "audit");
broker.BindQueue("/", q, "events", "user.*");
await using var sub = broker.Subscribe("/", q, async msg =>
{
Console.WriteLine(msg.BodyAsString()); // completes = ack, throws = nack(requeue)
}, prefetch: 100, concurrency: 4);
broker.Publish("/", "events", "user.created", Encoding.UTF8.GetBytes("hello"));
await broker.PublishConfirmedAsync("/", "events", "user.created", body); // waits for the disk writeЧерез DI (ASP.NET Core / Worker Service):
Via DI (ASP.NET Core / Worker Service):
builder.Services.AddBsaMq(builder.Configuration); // "BsaMq" section
var app = builder.Build();
app.MapBsaMqManagement(); // optional: API + UI on the app portsСоставComponents
| КомпонентComponent | НазначениеPurpose |
|---|---|
Bsa.MQ.Core | Ядро: AMQP 0-9-1, exchanges, очереди, журнал, пользователи, статистика, in-process API. Зависимости — только Microsoft.Extensions.Logging.Abstractions и System.IO.Pipelines.Core: AMQP 0-9-1, exchanges, queues, journal, users, statistics, in-process API. Dependencies: only Microsoft.Extensions.Logging.Abstractions and System.IO.Pipelines. |
Bsa.MQ.Hosting | services.AddBsaMq(...) — брокер в Generic Host / ASP.NET Core.services.AddBsaMq(...) — the broker in Generic Host / ASP.NET Core. |
Bsa.MQ.Management | app.MapBsaMqManagement() — management API, /metrics, веб-интерфейс.app.MapBsaMqManagement() — management API, /metrics, web UI. |
Bsa.MQ.Server | Готовый сервер: консоль, служба Windows или systemd.A ready server: console, Windows service or systemd. |
Bsa.MQ.PerfTest | Нагрузочный тест — аналог rabbitmq-perf-test — для сравнения с RabbitMQ на одной машине.A load test — like rabbitmq-perf-test — to compare with RabbitMQ on the same machine. |
Совместимость с RabbitMQRabbitMQ compatibility
| ОбластьArea | Что реализованоWhat is implemented |
|---|---|
| ПротоколProtocol | connection.* (PLAIN, AMQPLAIN, heartbeats, blocked/unblocked, update-secret), channel.*, exchange.*, queue.*, basic.*, confirm.select, tx.*connection.* (PLAIN, AMQPLAIN, heartbeats, blocked/unblocked, update-secret), channel.*, exchange.*, queue.*, basic.*, confirm.select, tx.* |
| Расширения RabbitMQRabbitMQ extensions | Publisher confirms, basic.nack, consumer cancel notify, exchange-to-exchange bindings, alternate exchange, per-consumer и global QoS, x-priority, direct reply-to, CC/BCC, consumer timeoutPublisher confirms, basic.nack, consumer cancel notify, exchange-to-exchange bindings, alternate exchange, per-consumer and global QoS, x-priority, direct reply-to, CC/BCC, consumer timeout |
| ExchangesExchanges | direct, fanout, topic, headers, amq.*; плагинные x-delayed-message, x-consistent-hash, x-local-randomdirect, fanout, topic, headers, amq.*; plugin types x-delayed-message, x-consistent-hash, x-local-random |
| ОчередиQueues | TTL, x-expires, x-max-length(-bytes), x-overflow, dead letter (x-death), x-max-priority, single active consumer, x-queue-type=quorum с x-delivery-limit (на одном узле), x-queue-mode=lazyTTL, x-expires, x-max-length(-bytes), x-overflow, dead letter (x-death), x-max-priority, single active consumer, x-queue-type=quorum with x-delivery-limit (single node), x-queue-mode=lazy |
| БезопасностьSecurity | Пользователи с хешами паролей, совместимыми с RabbitMQ, права configure/write/read, vhosts, loopback_users, TLS (AMQPS)Users with RabbitMQ-compatible password hashes, configure/write/read permissions, vhosts, loopback_users, TLS (AMQPS) |
| АдминистрированиеAdministration | Политики, применяемые на лету; импорт и экспорт definitions из rabbitmqctl export_definitions; credit flow для издателей; утилита bsamqctlPolicies applied on the fly; import and export of definitions from rabbitmqctl export_definitions; publisher credit flow; the bsamqctl CLI |
Тексты ошибок совпадают с RabbitMQ (NOT_FOUND - no queue 'x' in vhost '/', PRECONDITION_FAILED - inequivalent arg …), поэтому код, который их разбирает, тоже работает.
Error texts match RabbitMQ (NOT_FOUND - no queue 'x' in vhost '/', PRECONDITION_FAILED - inequivalent arg …), so code that parses them keeps working.
Пока нет: кластер и репликация, streams, AMQP 1.0 / MQTT / STOMP, topic permissions, OAuth 2. Кластер на Raft — следующий этап развития.
Not yet available: clustering and replication, streams, AMQP 1.0 / MQTT / STOMP, topic permissions, OAuth 2. A Raft-based cluster is the next stage.
ЛицензияLicense
BSD-2-Clause: свободное использование, изменение и распространение, в том числе в коммерческих продуктах.
BSD-2-Clause: free use, modification and redistribution, including in commercial products.