ModulusKit.Messaging
1.2.3
See the version list below for details.
dotnet add package ModulusKit.Messaging --version 1.2.3
NuGet\Install-Package ModulusKit.Messaging -Version 1.2.3
<PackageReference Include="ModulusKit.Messaging" Version="1.2.3" />
<PackageVersion Include="ModulusKit.Messaging" Version="1.2.3" />
<PackageReference Include="ModulusKit.Messaging" />
paket add ModulusKit.Messaging --version 1.2.3
#r "nuget: ModulusKit.Messaging, 1.2.3"
#:package ModulusKit.Messaging@1.2.3
#addin nuget:?package=ModulusKit.Messaging&version=1.2.3
#tool nuget:?package=ModulusKit.Messaging&version=1.2.3
Modulus.Messaging
Messaging library for .NET modular monoliths with MassTransit integration, supporting RabbitMQ, Azure Service Bus, and in-memory transports with a transactional outbox.
Installation
dotnet add package ModulusKit.Messaging
Setup
services.AddModulusMessaging(options =>
{
options.Transport = Transport.InMemory;
options.Assemblies.Add(typeof(Program).Assembly);
});
Transport Configuration
// RabbitMQ
services.AddModulusMessaging(options =>
{
options.Transport = Transport.RabbitMq;
options.ConnectionString = "amqp://guest:guest@localhost:5672";
options.Assemblies.Add(typeof(Program).Assembly);
});
// Azure Service Bus
services.AddModulusMessaging(options =>
{
options.Transport = Transport.AzureServiceBus;
options.ConnectionString = "Endpoint=sb://...";
options.Assemblies.Add(typeof(Program).Assembly);
});
Outbox Options
services.AddModulusMessaging(options =>
{
options.Transport = Transport.RabbitMq;
options.ConnectionString = "amqp://...";
options.OutboxPollInterval = TimeSpan.FromSeconds(5); // default
options.OutboxBatchSize = 100; // default
options.Assemblies.Add(typeof(Program).Assembly);
});
Publishing Events
public record OrderShipped(Guid OrderId, DateTime ShippedAt)
: IntegrationEvent;
// Publish directly via the message bus
await messageBus.Publish(new OrderShipped(orderId, DateTime.UtcNow));
// Or store in the outbox for reliable delivery
await outboxStore.Save(new OrderShipped(orderId, DateTime.UtcNow));
When using the outbox, events are stored in your database within the same transaction as your business data. A background OutboxProcessor polls for pending messages and publishes them via MassTransit.
Handling Events
public class OrderShippedHandler : IIntegrationEventHandler<OrderShipped>
{
public async Task Handle(OrderShipped @event, CancellationToken ct)
{
// Handle the cross-module event
}
}
Handlers are auto-discovered from the assemblies you provide in MessagingOptions.Assemblies and registered as scoped services.
Switching Transports
To switch from in-memory to RabbitMQ or Azure Service Bus, change the Transport property and provide a connection string. No code changes are needed in your handlers or publishers — the transport is fully abstracted.
Learn More
See the Modulus repository for full documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- MassTransit (>= 7.3.1)
- MassTransit.Azure.ServiceBus.Core (>= 7.3.1)
- MassTransit.Extensions.DependencyInjection (>= 7.3.1)
- MassTransit.RabbitMQ (>= 7.3.1)
- Microsoft.EntityFrameworkCore (>= 10.0.3)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.3)
- ModulusKit.Messaging.Abstractions (>= 1.2.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.