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
<PackageReference Include="Muonroi.Messaging.Abstractions" Version="2.0.2" />
<PackageVersion Include="Muonroi.Messaging.Abstractions" Version="2.0.2" />
<PackageReference Include="Muonroi.Messaging.Abstractions" />
paket add Muonroi.Messaging.Abstractions --version 2.0.2
#r "nuget: Muonroi.Messaging.Abstractions, 2.0.2"
#:package Muonroi.Messaging.Abstractions@2.0.2
#addin nuget:?package=Muonroi.Messaging.Abstractions&version=2.0.2
#tool nuget:?package=Muonroi.Messaging.Abstractions&version=2.0.2
Muonroi.Messaging.Abstractions
Contracts, event definitions, and routing abstractions for distributed messaging in the Muonroi ecosystem.
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) andIntegrationEvent(cross-process) to enforce architectural boundaries. - Message Envelopes:
IMuonroiMessageEnvelopeensures every message carries required metadata, such as Correlation IDs, Trace IDs, and Tenant context, enabling seamless distributed tracing. - Idempotency Guarantees: Includes the
[Idempotent]attribute andIMessageInboxStorecontracts to prevent duplicate message processing (exactly-once semantics). - Outbox Pattern Contracts:
IOutboxRelayServiceandEventOutboxprovide the blueprint for transactional outbox implementations, ensuring atomicity between database writes and message publishing. - Dynamic Routing: Exposes
IMessageRouter,IMessageRoutingRule, andIDynamicRoutingTableStoreto allow complex, content-based message routing at runtime. - Internal Entity Events: Pre-defined events like
MEntityCreatedEventandMEntityChangedEventfor 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 providingId,CreationDate, and metadata headers.DomainEvent: Base class for events strictly confined to a single domain/bounded context, typically dispatched viaMuonroi.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
IntegrationEventinstances automatically propagate tenant IDs. - Muonroi.Core.Abstractions: Integrates with trace contexts to populate the
TraceIdon 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 | 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
- Muonroi.Core (>= 2.0.2)
- Muonroi.Core.Abstractions (>= 2.0.2)
- Muonroi.Mediator (>= 2.0.2)
- Muonroi.Tenancy.Abstractions (>= 2.0.2)
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 | 469 | 8/26/2026 |
| 2.0.1 | 363 | 8/26/2026 |
| 2.0.0 | 385 | 8/14/2026 |
| 1.0.0-alpha.18 | 121 | 8/14/2026 |