Muonroi.Messaging.Abstractions 2.0.2

dotnet add package Muonroi.Messaging.Abstractions --version 2.0.2
                    
NuGet\Install-Package Muonroi.Messaging.Abstractions -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.Abstractions" 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.Abstractions" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.Messaging.Abstractions" />
                    
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.Abstractions --version 2.0.2
                    
#r "nuget: Muonroi.Messaging.Abstractions, 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.Abstractions@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.Abstractions&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.Messaging.Abstractions&version=2.0.2
                    
Install as a Cake Tool

Muonroi.Messaging.Abstractions

Contracts, event definitions, and routing abstractions for distributed messaging in the Muonroi ecosystem.

NuGet License

Overview

The Muonroi.Messaging.Abstractions package provides the core contracts and base classes required to implement distributed, asynchronous messaging. By standardizing the concepts of Domain Events, Integration Events, Message Envelopes, and Outbox/Inbox patterns, this package ensures that microservices can communicate reliably without being tightly coupled to a specific underlying message broker (like RabbitMQ or Azure Service Bus).

This package defines what a message is and how it should be routed and tracked, while concrete implementations (like Muonroi.Messaging.MassTransit) handle the actual transport.

Use this package when you are defining the shared integration contracts for your microservices, or when building custom routing and outbox logic.

Features

  • Standardized Event Types: Provides distinct base classes for DomainEvent (in-process) and IntegrationEvent (cross-process) to enforce architectural boundaries.
  • Message Envelopes: IMuonroiMessageEnvelope ensures every message carries required metadata, such as Correlation IDs, Trace IDs, and Tenant context, enabling seamless distributed tracing.
  • Idempotency Guarantees: Includes the [Idempotent] attribute and IMessageInboxStore contracts to prevent duplicate message processing (exactly-once semantics).
  • Outbox Pattern Contracts: IOutboxRelayService and EventOutbox provide the blueprint for transactional outbox implementations, ensuring atomicity between database writes and message publishing.
  • Dynamic Routing: Exposes IMessageRouter, IMessageRoutingRule, and IDynamicRoutingTableStore to allow complex, content-based message routing at runtime.
  • Internal Entity Events: Pre-defined events like MEntityCreatedEvent and MEntityChangedEvent for automatic CDC (Change Data Capture) style broadcasts.

Installation

dotnet add package Muonroi.Messaging.Abstractions

Quick Start

Defining an Integration Event

Inherit from the base IntegrationEvent class to define an event that will be broadcasted to other services.

using Muonroi.Messaging.Abstractions.Events;
using System;

public class OrderPlacedIntegrationEvent : IntegrationEvent
{
    public Guid OrderId { get; init; }
    public string CustomerId { get; init; }
    public decimal TotalAmount { get; init; }

    public OrderPlacedIntegrationEvent(Guid orderId, string customerId, decimal totalAmount)
        : base() // Base constructor automatically sets EventId, CreationDate
    {
        OrderId = orderId;
        CustomerId = customerId;
        TotalAmount = totalAmount;
    }
}

Enforcing Idempotency

When creating a handler in your consuming service, you can mark it as idempotent. The underlying infrastructure (when implemented) will use the IMessageInboxStore to ensure this handler is only executed once per message ID.

using Muonroi.Messaging.Abstractions.Attributes;
using System.Threading.Tasks;

[Idempotent(StateTtlDays = 7)]
public class OrderPlacedHandler
{
    public async Task HandleAsync(OrderPlacedIntegrationEvent @event)
    {
        // This logic is guaranteed to run exactly once per event.Id
        await _inventoryService.ReserveStockAsync(@event.OrderId);
    }
}

API Reference

Event Types

  • IIntegrationEvent: Marker interface for events crossing service boundaries.
  • IntegrationEvent: Base class providing Id, CreationDate, and metadata headers.
  • DomainEvent: Base class for events strictly confined to a single domain/bounded context, typically dispatched via Muonroi.Mediator.

Envelopes and Routing

  • IMuonroiMessageEnvelope<T>: Wraps a raw message with standardized headers (TraceId, TenantId, CorrelationId).
  • IMessageRouter: Evaluates a message against configured rules to determine its destination(s).
  • IMessageRoutingRule: A specific condition (e.g., "if TenantId == 'X', route to Topic Y").
  • IDynamicRoutingTableStore: A persistent store for updating routing rules at runtime without redeploying.

Reliability (Outbox/Inbox)

  • EventOutbox: An entity representing a serialized event waiting to be dispatched.
  • IOutboxRelayService: A background worker contract responsible for polling the Outbox and dispatching via the broker.
  • IMessageInboxStore: A contract for recording processed message IDs to achieve idempotency.

Sagas

  • IMuonroiSaga: Base interface for long-running, stateful message orchestration (Sagas/Process Managers).

Integration

Muonroi.Messaging.Abstractions provides the blueprints utilized by:

  • Muonroi.Messaging.MassTransit: Implements the actual transport, connecting these abstractions to RabbitMQ/Azure Service Bus.
  • Muonroi.Tenancy.Abstractions: Ensures IntegrationEvent instances automatically propagate tenant IDs.
  • Muonroi.Core.Abstractions: Integrates with trace contexts to populate the TraceId on outgoing envelopes.

Ecosystem Combinations

Great standalone. Becomes significantly more powerful when combined.

+ Messaging.MassTransit → Transport Implementation

MassTransit implements IMessageBus, IEventPublisher contracts.

+ Data.EntityFrameworkCore → Reliable Outbox

IOutboxRepository stored via EF, IDomainEvent raised in DbContext.SaveChanges.

+ Tenancy → Distributed Context

IIntegrationEvent carries TenantId in headers automatically.

Full Messaging Stack

builder.Services
    .AddMessagingAbstractions(config)
    .AddMassTransit(config);

Samples

See the working example in Quickstart.Messaging.Abstractions.

License

Apache 2.0 — see LICENSE-APACHE.

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 (5)

Showing the top 5 NuGet packages that depend on Muonroi.Messaging.Abstractions:

Package Downloads
Muonroi.Data.EntityFrameworkCore

Entity Framework Core infrastructure for Muonroi: MDbContext with audit, soft-delete, multi-tenant filters, and repository base.

Muonroi.RuleEngine.Runtime

Runtime orchestration layer for Muonroi RuleEngine, providing execution pipelines and integration points for rule evaluation services.

Muonroi.Caching.Redis

Package Description

Muonroi.Data.EntityFrameworkCore.Events

Event dispatch, outbox persistence, and saga support for Muonroi Data.EntityFrameworkCore. Adds Mediator and Messaging integration on top of the persistence-only core.

Muonroi.Messaging.MassTransit

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 479 8/26/2026
2.0.1 363 8/26/2026
2.0.0 387 8/14/2026
1.0.0-alpha.18 123 8/14/2026