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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Muonroi.Messaging.MassTransit" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.Messaging.MassTransit" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.Messaging.MassTransit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Muonroi.Messaging.MassTransit --version 2.0.2
                    
#r "nuget: Muonroi.Messaging.MassTransit, 2.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Muonroi.Messaging.MassTransit@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Muonroi.Messaging.MassTransit&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.Messaging.MassTransit&version=2.0.2
                    
Install as a Cake Tool

Muonroi.Messaging.MassTransit

MassTransit integration implementing Muonroi messaging contracts with RabbitMQ and Kafka support, pipeline filters, and OTel instrumentation.

NuGet License

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 on BusType.
  • Tenant Context Propagation: TenantContextConsumeFilter and MuonroiContextPublishFilter ensure 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: TenantQuotaMessagingFilter enforces message processing rate limits on a per-tenant basis.
  • Rule Engine Routing: RuleEngineRoutingFilter evaluates dynamic routing rules to control message flow at runtime.
  • Idempotent Inbox: MuonroiInboxFilter ensures exactly-once processing guarantees.
  • Outbox Relay: Implements OutboxRelayBackgroundService to 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.2 96 8/26/2026
2.0.1 101 8/26/2026
2.0.0 122 8/14/2026