Muonroi.Messaging.MassTransit
2.0.2
dotnet add package Muonroi.Messaging.MassTransit --version 2.0.2
NuGet\Install-Package Muonroi.Messaging.MassTransit -Version 2.0.2
<PackageReference Include="Muonroi.Messaging.MassTransit" Version="2.0.2" />
<PackageVersion Include="Muonroi.Messaging.MassTransit" Version="2.0.2" />
<PackageReference Include="Muonroi.Messaging.MassTransit" />
paket add Muonroi.Messaging.MassTransit --version 2.0.2
#r "nuget: Muonroi.Messaging.MassTransit, 2.0.2"
#:package Muonroi.Messaging.MassTransit@2.0.2
#addin nuget:?package=Muonroi.Messaging.MassTransit&version=2.0.2
#tool nuget:?package=Muonroi.Messaging.MassTransit&version=2.0.2
Muonroi.Messaging.MassTransit
MassTransit integration implementing Muonroi messaging contracts with RabbitMQ and Kafka support, pipeline filters, and OTel instrumentation.
Overview
The Muonroi.Messaging.MassTransit package provides a robust implementation of the Muonroi.Messaging.Abstractions contracts using the MassTransit framework. It abstracts away the boilerplate of configuring message brokers while injecting Muonroi's cross-cutting ecosystem concerns (such as multi-tenancy, rate limiting, and observability) directly into the messaging pipeline.
This package natively supports RabbitMQ and Kafka as underlying transports via RabbitMqBusConfigurator and KafkaBusConfigurator. It employs MassTransit's powerful middleware pipeline to inject specialized filters that handle trace context propagation, tenant context extraction, quota enforcement, and integration with the rule engine.
Features
- Multi-Broker Support: Configuration wrappers (
RabbitMqBusConfigurator,KafkaBusConfigurator) for rapid, environment-driven broker setup based onBusType. - Tenant Context Propagation:
TenantContextConsumeFilterandMuonroiContextPublishFilterensure that the current Tenant ID is injected into outgoing message headers and correctly hydrated in the consuming service's context. - Observability: Includes pipeline filters (
EcsConsumeLoggingFilter,EcsPublishLoggingFilter) that enrich spans and logs with ECS-compliant metadata. - Quota Integration:
TenantQuotaMessagingFilterenforces message processing rate limits on a per-tenant basis. - Rule Engine Routing:
RuleEngineRoutingFilterevaluates dynamic routing rules to control message flow at runtime. - Idempotent Inbox:
MuonroiInboxFilterensures exactly-once processing guarantees. - Outbox Relay: Implements
OutboxRelayBackgroundServiceto reliably poll and dispatch events from the persistent outbox to the message broker.
Installation
dotnet add package Muonroi.Messaging.MassTransit
Quick Start
Configuring the Bus
Register MassTransit and the Muonroi pipeline filters in your host initialization.
using Microsoft.Extensions.DependencyInjection;
using MassTransit;
using Muonroi.Messaging.MassTransit;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMassTransit(x =>
{
x.AddConsumers(typeof(Program).Assembly);
x.UsingRabbitMq((context, cfg) =>
{
// Bind Muonroi pipeline filters
cfg.UseMuonroiFilters(context);
cfg.Host(builder.Configuration["MessageBus:RabbitMq:Host"], "/", h =>
{
h.Username(builder.Configuration["MessageBus:RabbitMq:Username"]);
h.Password(builder.Configuration["MessageBus:RabbitMq:Password"]);
});
cfg.ConfigureEndpoints(context);
});
});
Creating a Consumer
Inherit from MuonroiConsumerBase<T>. Due to the injected pipeline filters, the ITenantContext will be automatically populated before your handler executes.
using MassTransit;
using Muonroi.Messaging.MassTransit;
using Muonroi.Tenancy.Abstractions;
public class OrderPlacedConsumer : MuonroiConsumerBase<OrderPlacedIntegrationEvent>
{
private readonly ITenantContextAccessor _tenantAccessor;
public OrderPlacedConsumer(ITenantContextAccessor tenantAccessor)
{
_tenantAccessor = tenantAccessor;
}
public override async Task Consume(ConsumeContext<OrderPlacedIntegrationEvent> context)
{
var tenantId = _tenantAccessor.Current.TenantId;
// Process message with tenant isolation...
}
}
Ecosystem Combinations
+ Muonroi.Tenancy.Core → Automated Context Propagation
By combining these packages, TenantContextConsumeFilter ensures that backend worker processes instantly know which tenant's context they are running under when a message is pulled from the queue, preventing accidental cross-tenant data corruption without any custom code in your consumers.
+ Muonroi.Governance.Abstractions → Tenant-Specific Throttling
Adding Governance allows TenantQuotaMessagingFilter to limit consumption rates based on the tenant's tier (e.g., Free vs. Enterprise), preventing noisy-neighbor issues during traffic spikes.
+ Muonroi.RuleEngine.CEP → Dynamic Message Routing
Enables RuleEngineRoutingFilter to dynamically redirect or drop messages at runtime based on complex event processing rules defined by administrators.
Full Reliable Messaging
builder.Services
.AddMassTransit(config)
.AddTenantContext(config)
.AddMuonroiObservability(config)
.AddEntityFrameworkOutbox(config);
Samples
License
Commercial License — see LICENSE-COMMERCIAL.
| 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.Core (>= 2.0.2)
- Muonroi.Core.Abstractions (>= 2.0.2)
- Muonroi.Data.EntityFrameworkCore (>= 2.0.2)
- Muonroi.Data.EntityFrameworkCore.Events (>= 2.0.2)
- Muonroi.Governance.Abstractions (>= 2.0.2)
- Muonroi.Logging.Abstractions (>= 2.0.2)
- Muonroi.Messaging.Abstractions (>= 2.0.2)
- Muonroi.Tenancy.Core (>= 2.0.2)
- 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)
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.