Tolitech.Application.Messaging 1.0.0-preview.4

This is a prerelease version of Tolitech.Application.Messaging.
dotnet add package Tolitech.Application.Messaging --version 1.0.0-preview.4
                    
NuGet\Install-Package Tolitech.Application.Messaging -Version 1.0.0-preview.4
                    
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="Tolitech.Application.Messaging" Version="1.0.0-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.Application.Messaging" Version="1.0.0-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="Tolitech.Application.Messaging" />
                    
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 Tolitech.Application.Messaging --version 1.0.0-preview.4
                    
#r "nuget: Tolitech.Application.Messaging, 1.0.0-preview.4"
                    
#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 Tolitech.Application.Messaging@1.0.0-preview.4
                    
#: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=Tolitech.Application.Messaging&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tolitech.Application.Messaging&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Tool

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

  1. Reference Tolitech.Application.Messaging in your project.
  2. Implement your integration events and handlers using the provided interfaces.
  3. Register handlers with MassTransit and configure the event bus.
  4. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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