Muonroi.Messaging.MassTransit
1.0.0-alpha.16
dotnet add package Muonroi.Messaging.MassTransit --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.Messaging.MassTransit -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.Messaging.MassTransit" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.Messaging.MassTransit" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.Messaging.MassTransit" />
paket add Muonroi.Messaging.MassTransit --version 1.0.0-alpha.16
#r "nuget: Muonroi.Messaging.MassTransit, 1.0.0-alpha.16"
#:package Muonroi.Messaging.MassTransit@1.0.0-alpha.16
#addin nuget:?package=Muonroi.Messaging.MassTransit&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.Messaging.MassTransit&version=1.0.0-alpha.16&prerelease
Muonroi.Messaging.MassTransit
MassTransit adapter for the Muonroi messaging platform — wires RabbitMQ or Kafka to the Muonroi execution context, tenancy, quota, rule engine, and EF Core outbox in a single
AddMessageBuscall.
This package implements the contracts defined in Muonroi.Messaging.Abstractions on top of MassTransit. It auto-configures consume, publish, and send filter pipelines that propagate tenant identity, enforce quota, apply rule-engine routing, and emit ECS-structured logs and OpenTelemetry traces — without requiring per-consumer boilerplate. Both RabbitMQ and Kafka transports are supported; the active transport is selected via configuration.
Commercial package — a valid Muonroi license that includes the
MessageBuspremium feature is required. TheAddMessageBuscall will throw at startup if the license check fails.
Installation
dotnet add package Muonroi.Messaging.MassTransit --prerelease
Quick Start
Add the section to appsettings.json:
{
"MessageBusConfigs": {
"BusType": "RabbitMq",
"RabbitMq": {
"Host": "localhost",
"VirtualHost": "/",
"Username": "guest",
"Password": "guest"
},
"Runtime": {
"RetryCount": 3,
"RetryIntervalMs": 500,
"PrefetchCount": 32,
"ConcurrentMessageLimit": 16,
"EnableInMemoryOutbox": true,
"EndpointPrefix": "myapp"
}
}
}
Register in Program.cs:
builder.Services.AddMessageBus(
builder.Configuration,
consumersAssembly: typeof(Program).Assembly);
// Optional: persistent EF Core outbox relay
builder.Services.AddOutboxRelay();
Implement a consumer by inheriting MuonroiConsumerBase<TMessage>:
public class OrderCreatedConsumer(
ISystemExecutionContextAccessor contextAccessor,
IMLog<OrderCreated> log)
: MuonroiConsumerBase<OrderCreated>(contextAccessor, log)
{
protected override Task HandleAsync(
ConsumeContext<OrderCreated> context,
ISystemExecutionContext executionContext,
CancellationToken cancellationToken)
{
log.Info("Order {OrderId} received for tenant {TenantId}",
context.Message.OrderId, executionContext.TenantId);
return Task.CompletedTask;
}
}
Publish a message with full auth context propagation:
await publishEndpoint.PublishWithAuthContext(
new OrderCreated { OrderId = id },
contextAccessor,
tenantContextPolicy,
cancellationToken);
Features
- Dual-transport: RabbitMQ (
MassTransit.RabbitMQ) and Kafka (MassTransit.Kafka) — selected byBusTypein config; no code changes required to switch. - Automatic context propagation:
AmqpContextConsumeFilterandMuonroiContextPublishFilter/MuonroiContextSendFilterstamp tenant ID, user ID, correlation ID, and access token into every message's headers. - Tenant context restore on consume:
TenantContextConsumeFilterrebuildsISystemExecutionContextfrom headers soHandleAsyncalways receives a fully-populated context. - Quota enforcement:
TenantQuotaMessagingFilter(publish + send) blocks messages when the tenant's messaging quota is exhausted; enabled viaEnableQuotaEnforcement: true. - Rule-engine routing:
RuleEngineRoutingFilterevaluates the Muonroi Rule Engine per message and can redirect or drop messages; enabled viaEnableRuleEngineRouting: true. Redis-backed dynamic routing table also available (EnableRedisRoutingTable: true). - ECS structured logging:
EcsConsumeLoggingFilter,EcsPublishLoggingFilter,EcsSendLoggingFilteremit ECS-compliant log entries on every message transit. - OpenTelemetry: traces (
MassTransit+MessageBusRuntimeTelemetrysources) and metrics (MassTransit+MessageBusRuntimeTelemetrymeters) registered automatically; includes ASP.NET Core and HTTP client instrumentation. - Health checks:
RabbitMqHealthCheckorKafkaHealthCheckregistered automatically based on the active transport. - Runtime policies: retry (interval), prefetch count, concurrency limit, and MassTransit in-memory outbox applied uniformly to all endpoints via
ApplyRuntimePolicies. - Persistent outbox relay:
AddOutboxRelayregistersOutboxRelayBackgroundService, which pollsIEventOutboxStore(EF Core) and publishes pendingEventOutboxrecords to the bus in configurable batches. - Saga bridge:
IMuonroiMassTransitSagacombinesIMuonroiSaga(vendor-neutral) withMassTransit.ISagaso saga state classes satisfy both contracts from a single implementation. - Message router:
AddMessageRouter<TMessage, TRouter>registers anIMessageRouter<TMessage>for rule-based routing without touching the consumer class. - Token masking:
MaskAccessTokenInHeaders: truesuppresses raw access tokens from outbound headers for zero-trust deployments.
Configuration
MessageBusConfigs (MessageBusConfigs section)
| Property | Type | Default | Description |
|---|---|---|---|
BusType |
BusType |
— | RabbitMq or Kafka |
RabbitMq |
RabbitMqConfigs |
null |
RabbitMQ connection settings |
Kafka |
KafkaConfigs |
null |
Kafka connection settings |
Runtime |
MessageBusRuntimeConfigs |
see below | Retry, concurrency, outbox |
OutboxRelay |
OutboxRelayConfigs |
see below | Persistent outbox relay |
MaskAccessTokenInHeaders |
bool |
false |
Suppress raw tokens in headers |
EnableQuotaEnforcement |
bool |
false |
Block messages on quota exceeded |
EnableRuleEngineRouting |
bool |
false |
Route via Rule Engine per message |
EnableRedisRoutingTable |
bool |
false |
Redis-backed dynamic routing |
MessageBusRuntimeConfigs
| Property | Default | Description |
|---|---|---|
RetryCount |
3 |
Message retry attempts |
RetryIntervalMs |
500 |
Interval between retries (ms) |
PrefetchCount |
32 |
Per-consumer prefetch |
ConcurrentMessageLimit |
16 |
Max concurrent messages |
EnableInMemoryOutbox |
true |
MassTransit in-memory deduplication outbox |
EndpointPrefix |
"" |
Kebab-case endpoint name prefix |
OutboxRelayConfigs
| Property | Default | Description |
|---|---|---|
Enabled |
true |
Enable the background relay |
PollingIntervalMs |
5000 |
How often to poll (ms) |
BatchSize |
100 |
Max events per poll cycle |
MaxRetryFailedCount |
5 |
Max failed-relay retries |
RabbitMqConfigs
| Property | Default | Description |
|---|---|---|
Host |
"" |
RabbitMQ hostname |
VirtualHost |
"/" |
AMQP virtual host |
Username |
"" |
Authentication username |
Password |
"" |
Authentication password |
Port |
5672 |
AMQP port |
UseSsl |
false |
Enable TLS |
SslServerName |
"" |
TLS server name |
HeartbeatSeconds |
30 |
AMQP heartbeat interval |
PublisherConfirmation |
true |
Require publisher confirms |
DeadLetterExchange |
"" |
DLX for failed messages |
UseQuorumQueues |
false |
Use quorum queues |
KafkaConfigs
| Property | Default | Description |
|---|---|---|
Host |
"" |
Kafka broker host |
Topic |
"" |
Default topic |
GroupId |
"consumer-group" |
Consumer group ID |
ClientId |
"muonroi-messagebus" |
Kafka client ID |
EnableAutoCommit |
true |
Auto-commit offsets |
SecurityProtocol |
"" |
e.g. SASL_SSL |
SaslMechanism |
"" |
e.g. PLAIN |
SaslUsername / SaslPassword |
"" |
SASL credentials |
DeadLetterTopic |
"" |
DLT for failed messages |
API Reference
| Type | Purpose |
|---|---|
MassTransitHandler |
Static class — AddMessageBus and AddOutboxRelay extension methods |
MuonroiConsumerBase<TMessage> |
Abstract base consumer; override HandleAsync to implement business logic |
MessageBusConfigs |
Root configuration class; section name "MessageBusConfigs" |
MessageBusRuntimeConfigs |
Retry, concurrency, outbox, and endpoint prefix settings |
OutboxRelayConfigs |
Persistent outbox polling settings |
RabbitMqConfigs |
RabbitMQ connection and topology settings |
KafkaConfigs |
Kafka connection and SASL settings |
BusType |
Enum: RabbitMq, Kafka |
IBusConfigurator |
Internal transport strategy interface (RabbitMqBusConfigurator, KafkaBusConfigurator) |
IMuonroiMassTransitSaga |
Saga contract bridging IMuonroiSaga and MassTransit.ISaga |
MassTransitFilterExtensions |
AddMessageRouter<TMessage,TRouter>, ApplyRuntimePolicies, UseMuonroiInbox |
PublishEndpointAuthExtensions |
PublishWithAuthContext<T> and PublishWithContext<T> — publish with full Muonroi envelope headers |
OutboxRelayBackgroundService |
BackgroundService + IOutboxRelayService; polls EF Core outbox and publishes to bus |
Samples
No dedicated sample exists for this package in the repository. The Quick Start snippet above is derived directly from the public API surface.
Compatibility
- Target framework:
net8.0 - License: Commercial — requires a Muonroi license with the
MessageBuspremium feature enabled
Related Packages
Muonroi.Messaging.Abstractions— vendor-neutral contracts (IMessageRouter<T>,IMuonroiSaga,IOutboxRelayService,IEventOutboxStore) that this package implementsMuonroi.Data.EntityFrameworkCore.Events— providesIEventOutboxStoreandEventOutboxfor the persistent outbox relayMuonroi.Tenancy.Core— providesITenantContextPolicyand tenant resolution used by the consume filterMuonroi.RuleEngine.Runtime— supplies the rule engine invoked byRuleEngineRoutingFilterMuonroi.Observability— shared OpenTelemetry setup extended by this package's tracing and metrics
License
Commercial — see LICENSE-COMMERCIAL. A license with the Premium.MessageBus feature is validated at startup via EnsureFeatureOrThrow.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Confluent.Kafka (>= 2.8.0)
- MassTransit (>= 8.3.6)
- MassTransit.Kafka (>= 8.3.6)
- MassTransit.RabbitMQ (>= 8.3.6)
- Muonroi.Auth (>= 1.0.0-alpha.16)
- Muonroi.Caching.Redis (>= 1.0.0-alpha.16)
- Muonroi.Core (>= 1.0.0-alpha.16)
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Data.EntityFrameworkCore (>= 1.0.0-alpha.16)
- Muonroi.Data.EntityFrameworkCore.Events (>= 1.0.0-alpha.16)
- Muonroi.Governance.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Logging.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Messaging.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Observability (>= 1.0.0-alpha.16)
- Muonroi.RuleEngine.Runtime (>= 1.0.0-alpha.16)
- Muonroi.Tenancy.Core (>= 1.0.0-alpha.16)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.9.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.9.0)
- OpenTelemetry.Instrumentation.Http (>= 1.9.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.9.0)
- RabbitMQ.Client (>= 7.0.0)
- Scriban (>= 7.2.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Muonroi.Messaging.MassTransit:
| Package | Downloads |
|---|---|
|
Muonroi.BuildingBlock.All
Metapackage for Muonroi Building Block - Includes all sub-packages for a complete infrastructure setup. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.16 | 62 | 6/22/2026 |
| 1.0.0-alpha.15 | 85 | 5/31/2026 |
| 1.0.0-alpha.14 | 82 | 5/15/2026 |
| 1.0.0-alpha.13 | 78 | 5/2/2026 |
| 1.0.0-alpha.12 | 80 | 4/2/2026 |
| 1.0.0-alpha.11 | 123 | 4/2/2026 |
| 1.0.0-alpha.8 | 157 | 3/28/2026 |
| 1.0.0-alpha.1 | 73 | 3/8/2026 |