LiteBus.Messaging.Abstractions 1.1.0

dotnet add package LiteBus.Messaging.Abstractions --version 1.1.0
                    
NuGet\Install-Package LiteBus.Messaging.Abstractions -Version 1.1.0
                    
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="LiteBus.Messaging.Abstractions" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LiteBus.Messaging.Abstractions" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="LiteBus.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 LiteBus.Messaging.Abstractions --version 1.1.0
                    
#r "nuget: LiteBus.Messaging.Abstractions, 1.1.0"
                    
#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.
#addin nuget:?package=LiteBus.Messaging.Abstractions&version=1.1.0
                    
Install LiteBus.Messaging.Abstractions as a Cake Addin
#tool nuget:?package=LiteBus.Messaging.Abstractions&version=1.1.0
                    
Install LiteBus.Messaging.Abstractions as a Cake Tool

<h1 align="center"><br> <a href="https://github.com/litenova/LiteBus"> <img src="assets/logo/icon.png"> </a> <br> LiteBus <br> </h1> <h4 align="center">A lightweight, flexible in-process mediator for implementing Command Query Separation (CQS)</h4> <p align="center"> <a href="https://github.com/litenova/LiteBus/actions/workflows/release.yml"> <img src="https://github.com/litenova/LiteBus/actions/workflows/release.yml/badge.svg" alt="CI/CD Badge" /> </a> <a href="https://codecov.io/gh/litenova/LiteBus" > <img src="https://codecov.io/gh/litenova/LiteBus/graph/badge.svg?token=XBNYITSV5A" alt="Code Coverage Badge" /> </a> <a href="https://www.nuget.org/packages/LiteBus"> <img src="https://img.shields.io/nuget/vpre/LiteBus.svg" alt="LiteBus Nuget Version" /> </a> </p> <p align="center"> For detailed documentation and examples, please visit the <a href="https://github.com/litenova/LiteBus/wiki"><b>Wiki</b></a>. </p>

Key Features

  • Built in .NET 8

  • Zero external dependencies - Completely standalone with no third-party dependencies

  • Reduced reflection usage - Optimized for performance with minimal reflection

  • DDD-friendly design - Support for plain domain events without library dependencies, keeping your domain model clean

  • Comprehensive messaging types:

    • ICommand / ICommand<TResult> - For state-changing operations
    • IQuery<TResult> - For data retrieval operations
    • IStreamQuery<TResult> - For streaming large datasets via IAsyncEnumerable<T>
    • IEvent - For notifications and event-driven architecture
    • Support for POCO objects as messages without library interfaces
  • Rich handler ecosystem:

    • Pre-handlers for validation and pre-processing
    • Post-handlers for notifications and side effects
    • Error handlers for centralized exception management
    • Support for generic handlers and messages
    • Handler ordering control
    • Contextual handler selection via tags and filters
  • Advanced features:

    • Covariant type handling for polymorphic dispatch
    • Execution context for cross-cutting concerns
    • Aborting execution flow when needed
    • Microsoft Dependency Injection integration

Quick Example

// Define a command with a result
public class CreateProductCommand : ICommand<ProductDto>
{
    public required string Name { get; init; }
    public required decimal Price { get; init; }
    public string? Description { get; init; }
}

// Implement a command handler
public class CreateProductCommandHandler : ICommandHandler<CreateProductCommand, ProductDto>
{
    private readonly IProductRepository _repository;
    
    public CreateProductCommandHandler(IProductRepository repository)
    {
        _repository = repository;
    }
    
    public async Task<ProductDto> HandleAsync(CreateProductCommand command, CancellationToken cancellationToken = default)
    {
        var product = new Product
        {
            Id = Guid.NewGuid(),
            Name = command.Name,
            Price = command.Price,
            Description = command.Description
        };
        
        await _repository.SaveAsync(product, cancellationToken);
        
        return new ProductDto
        {
            Id = product.Id,
            Name = product.Name,
            Price = product.Price,
            Description = product.Description
        };
    }
}

// Configure in ASP.NET Core
services.AddLiteBus(liteBus =>
{
    liteBus.AddCommandModule(module =>
    {
        module.RegisterFromAssembly(typeof(Program).Assembly);
    });
    
    liteBus.AddQueryModule(module =>
    {
        module.RegisterFromAssembly(typeof(Program).Assembly);
    });
    
    liteBus.AddEventModule(module =>
    {
        module.RegisterFromAssembly(typeof(Program).Assembly);
    });
});

// Use in a controller or service
public class ProductsController : ControllerBase
{
    private readonly ICommandMediator _commandMediator;
    
    public ProductsController(ICommandMediator commandMediator)
    {
        _commandMediator = commandMediator;
    }
    
    [HttpPost]
    public async Task<ActionResult<ProductDto>> CreateProduct(CreateProductCommand command)
    {
        var product = await _commandMediator.SendAsync(command);
        return Ok(product);
    }
}

Documentation

For comprehensive documentation, including detailed explanations, advanced features, and best practices, please visit the Wiki.

Installation

LiteBus is available as NuGet packages:

dotnet add package LiteBus
dotnet add package LiteBus.Extensions.MicrosoftDependencyInjection

Or specific modules:

dotnet add package LiteBus.Commands
dotnet add package LiteBus.Queries
dotnet add package LiteBus.Events

License

LiteBus is licensed under the MIT License. See the LICENSE file for details.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (6)

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

Package Downloads
LiteBus.Commands.Abstractions

LiteBus is a lightweight, flexible in-process mediator for implementing Command Query Separation (CQS) patterns in .NET applications.

LiteBus.Queries.Abstractions

LiteBus is a lightweight, flexible in-process mediator for implementing Command Query Separation (CQS) patterns in .NET applications.

LiteBus.Messaging

LiteBus is a lightweight, flexible in-process mediator for implementing Command Query Separation (CQS) patterns in .NET applications.

LiteBus.Events.Abstractions

LiteBus is a lightweight, flexible in-process mediator for implementing Command Query Separation (CQS) patterns in .NET applications.

LiteBus.Events

LiteBus is a lightweight, flexible in-process mediator for implementing Command Query Separation (CQS) patterns in .NET applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 0 4/24/2025
1.0.0 154 4/19/2025
0.25.1 256 4/17/2025
0.25.0 240 4/13/2025
0.24.4 223 4/10/2025
0.24.3 3,343 5/2/2024
0.24.2 289 4/16/2024
0.24.1 239 1/30/2024
0.23.1 2,264 1/11/2024
0.23.0 331 12/23/2023
0.22.0 281 12/23/2023
0.21.0 304 12/18/2023
0.20.2 343 12/8/2023
0.20.1 287 12/5/2023
0.20.0 1,256 12/5/2023
0.19.1 245 11/25/2023
0.19.0 250 11/23/2023
0.18.4 324 11/23/2023
0.18.3 315 11/23/2023
0.18.2 329 11/22/2023
0.18.1 941 11/6/2023
0.18.0 350 11/1/2023
0.17.1 334 10/20/2023
0.16.0 432 9/26/2023
0.15.1 3,629 6/23/2023
0.15.0 683 6/23/2023
0.14.1 682 6/22/2023
0.14.0 1,086 11/30/2022
0.13.0 2,169 10/7/2022
0.12.0 10,147 1/6/2022
0.11.3 5,206 12/27/2021
0.11.2 1,347 12/27/2021
0.11.1 1,309 12/26/2021
0.11.0 1,330 12/23/2021
0.10.2 1,311 12/22/2021
0.10.1 1,289 12/20/2021
0.10.0 1,422 12/15/2021
0.9.1 2,104 10/25/2021
0.9.0 1,757 10/25/2021
0.8.1 5,126 10/9/2021
0.8.0 2,314 9/7/2021
0.7.0 2,570 8/19/2021
0.6.3 2,168 8/9/2021
0.6.2 1,768 8/9/2021
0.6.1 1,791 8/9/2021
0.6.0 1,818 8/9/2021
0.5.0 1,846 7/8/2021
0.4.0 2,120 4/13/2021
0.3.1 1,815 4/13/2021
0.2.1 1,709 4/9/2021
0.2.0 1,735 4/6/2021
0.1.0 1,925 3/17/2021