Tolitech.Application.Messaging
1.0.0-preview.4
dotnet add package Tolitech.Application.Messaging --version 1.0.0-preview.4
NuGet\Install-Package Tolitech.Application.Messaging -Version 1.0.0-preview.4
<PackageReference Include="Tolitech.Application.Messaging" Version="1.0.0-preview.4" />
<PackageVersion Include="Tolitech.Application.Messaging" Version="1.0.0-preview.4" />
<PackageReference Include="Tolitech.Application.Messaging" />
paket add Tolitech.Application.Messaging --version 1.0.0-preview.4
#r "nuget: Tolitech.Application.Messaging, 1.0.0-preview.4"
#:package Tolitech.Application.Messaging@1.0.0-preview.4
#addin nuget:?package=Tolitech.Application.Messaging&version=1.0.0-preview.4&prerelease
#tool nuget:?package=Tolitech.Application.Messaging&version=1.0.0-preview.4&prerelease
Tolitech.Application.Messaging
Overview
Tolitech.Application.Messaging is a lightweight .NET library designed to simplify the implementation of event-driven architectures. It provides abstractions for event bus, integration event handling, and the Outbox pattern, enabling reliable and scalable messaging between microservices and distributed systems.
Features
- Event Bus Abstraction: Interface for publishing integration events asynchronously.
- Integration Event Handler: Interface for handling events, compatible with MassTransit consumers.
- Outbox Pattern: Interface for reliable event registration and deferred processing.
- MassTransit Integration: Built to work seamlessly with MassTransit and Tolitech.Messaging.IntegrationEvents.
- Extensibility: Easily integrate with custom infrastructure and business logic.
Main Interfaces
IEventBus
Abstraction for publishing integration events.
public interface IEventBus
{
Task PublishAsync<T>(T message, CancellationToken cancellationToken)
where T : IIntegrationEvent;
}
IIntegrationEventHandler<TMessage>
Handler for integration events (MassTransit consumer).
public interface IIntegrationEventHandler<in TMessage> : IConsumer<TMessage>
where TMessage : class, IIntegrationEvent;
IOutbox
Outbox pattern for reliable event registration and deferred processing.
public interface IOutbox
{
void RegisterIntegrationEvent(IIntegrationEvent ev);
void RegisterIntegrationEvent(IIntegrationEvent ev, TimeSpan delay);
void RegisterIntegrationEvent(IIntegrationEvent ev, DateTimeOffset enqueueAt);
IReadOnlyList<IntegrationEventEnvelope> GetIntegrationEventEnvelopes();
void ClearIntegrationEventEnvelopes();
}
Example Usage
Publishing an Event
public class OrderCreatedIntegrationEvent : IIntegrationEvent
{
public Guid OrderId { get; set; }
}
// Publishing the event
await eventBus.PublishAsync(new OrderCreatedIntegrationEvent { OrderId = orderId }, cancellationToken);
Handling an Event
public class OrderCreatedHandler : IIntegrationEventHandler<OrderCreatedIntegrationEvent>
{
public async Task Consume(ConsumeContext<OrderCreatedIntegrationEvent> context)
{
// Handle the event
var orderId = context.Message.OrderId;
}
}
Using the Outbox
// Register event for later processing
outbox.RegisterIntegrationEvent(new OrderCreatedIntegrationEvent { OrderId = orderId });
// Register with delay
outbox.RegisterIntegrationEvent(new OrderCreatedIntegrationEvent { OrderId = orderId }, TimeSpan.FromMinutes(10));
// Register for specific time
outbox.RegisterIntegrationEvent(new OrderCreatedIntegrationEvent { OrderId = orderId }, DateTimeOffset.UtcNow.AddHours(1));
// Retrieve and clear events
var envelopes = outbox.GetIntegrationEventEnvelopes();
outbox.ClearIntegrationEventEnvelopes();
Integration Steps
- Reference Tolitech.Application.Messaging in your project.
- Implement your integration events and handlers using the provided interfaces.
- Register handlers with MassTransit and configure the event bus.
- Use the Outbox for reliable event registration if needed.
Summary
Tolitech.Application.Messaging streamlines event-driven development in .NET, providing robust abstractions for messaging, event handling, and reliability in distributed systems.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- MassTransit (>= 8.5.1)
- Tolitech.Messaging.IntegrationEvents (>= 1.0.0-preview.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Tolitech.Application.Messaging:
Package | Downloads |
---|---|
Tolitech.Infrastructure.Persistence.EntityFrameworkCore
The Tolitech.Infrastructure.Persistence.EntityFrameworkCore repository provides a foundational implementation for the Repository pattern, Unit of Work, and Specification Query Builder using Entity Framework Core. Simplify database interaction, promote code organization, and maintenance using these widely recognized patterns. |
|
Tolitech.Infrastructure.Messaging
The Tolitech.Infrastructure.Messaging library is designed to facilitate the publishing of integration events in a straightforward and efficient manner. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-preview.4 | 432 | 7/21/2025 |
1.0.0-preview.3 | 124 | 7/3/2025 |
1.0.0-preview.2 | 115 | 7/3/2025 |
1.0.0-preview.1 | 118 | 12/12/2024 |