Netrilo.Infrastructure.Common.Bus 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Netrilo.Infrastructure.Common.Bus --version 1.0.2
                    
NuGet\Install-Package Netrilo.Infrastructure.Common.Bus -Version 1.0.2
                    
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="Netrilo.Infrastructure.Common.Bus" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Netrilo.Infrastructure.Common.Bus" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Netrilo.Infrastructure.Common.Bus" />
                    
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 Netrilo.Infrastructure.Common.Bus --version 1.0.2
                    
#r "nuget: Netrilo.Infrastructure.Common.Bus, 1.0.2"
                    
#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 Netrilo.Infrastructure.Common.Bus@1.0.2
                    
#: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=Netrilo.Infrastructure.Common.Bus&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Netrilo.Infrastructure.Common.Bus&version=1.0.2
                    
Install as a Cake Tool

Netrilo.Infrastructure.Common.Bus

Part of the Netrilo.Infrastructure SDK

๐Ÿ“ฆ NuGet

NuGet

๐Ÿ“– Description

Implements an in-memory or pluggable event bus for domain event publishing.

  • Event Stores for event driven systems including stores, projection, and snapshot
  • Event Bus supporting query and command handlers
  • Implementing Message Brokers with MassTransit supporting RabbitMQ, Azure Service Bus, and Kafka
  • Supporting Domain-Driven-Design architecture like aggregates and projection
  • Simple pub/sub for decoupled messaging
  • Supports mediator patterns for Clean Architecture Design
  • Designed for testability

๐Ÿš€ Installation

dotnet add package Netrilo.Infrastructure.Common.Bus

๐Ÿงฉ Bus Extension

Firstly, add this namespace in your code:

using Netrilo.Infrastructure.Common.Bus;

Then, simply register the Event Bus and mapping profiles including all AddMediatR and mapper assemblies like the following code in your program Startup:

services.AddCore(typeof(Startup));

If you have multiple dependent projects including assemblies need to be registered, this function can be overloaded by multiple optional arguments like following code:

services.AddCore(typeof(Startup), typeof(ChildProject1), typeof(ChildProject2), ...);

Finally, you will have the access to the following services over DI:

  • ICommandBus
  • IQueryBus
  • IEventBus

Sample Usage

eventBus.Publish(new OrderCreatedEvent(...));

๐Ÿงฉ Event Store Extension

Event Store extension supports Domain-Driven-Design and Event-Driven systems with supporting different storages.

To use the event stores extension, firstly add this namespace in your code:

using Netrilo.Infrastructure.Common.Bus.EventStores;

Then, simply register the Event Store like the following code in your program Startup:

services.AddEventStore<TAggregate>(IConfiguration Configuration, Action<DbContextOptionsBuilder> dbContextOptions = null);

This Event Store supports multiple stores including:

  • EfCore
  • Mongo

Which you can configure in EventStoresOptions variables in appsettings.json.


๐Ÿงฉ Message Brokers Extensions

Message brokers part works with MassTransit and handles the Event Messaging and Message Delivering via EventBus and Event Listener between the endpoints, and supports multiple type of MessageBroker, including:

  • RabbitMQ
  • AzureServiceBus
  • Kafka

Which you can configure in MessageBrokersOptions variables in appsettings.json. Additionally, you have all features and functionalities of MassTransit to work with (read the full documentation of MassTransit in this link).

๐Ÿงฉ Message Brokers Installation

You can easily register mentioned MessageBrokers by an overloaded function named AddMessageBroker in your project Startup as the following code:

Configure RabbitMQ and Kafka

services.AddMessageBroker(
            IConfiguration Configuration,
            Type[] consumers,
            Action<IBusRegistrationConfigurator> busRegistrationConfigurator = null,
            Action<IBusRegistrationContext, IRabbitMqBusFactoryConfigurator> rabbitMqBusFactoryConfigurator = null
            )

Configure AzureServiceBus

services.AddMessageBroker(
            IConfiguration Configuration,
            Type[] consumers,
            Action<IBusRegistrationConfigurator> busRegistrationConfigurator = null,
            Action<IBusRegistrationContext, IServiceBusBusFactoryConfigurator> azureBusFactoryConfigurator = null
            )

In addition, you can get and register all Consumers by reflection to register as the following code:

services.AddMessageBroker(Configuration, ConsumersExtension.All(), default)

This will register the considered message broker and Event Listener to publish messages and events to the consumers and endpoints by injection of IEventListener and use that like the following function:

public async Task PublishOrderCreated
    {
        eventListener.Publish<OrderCreatedEvent>(new OrderCreatedEvent());
    }

The property eventListener is type of IEventListener which should be injected in your class constructor and OrderCreatedEvent must be type of IEvent.


๐Ÿงช Tests

Run the following command to run the tests:

dotnet test .\Tests\Netrilo.Infrastructure.Common.Bus.UnitTests\Netrilo.Infrastructure.Common.Bus.UnitTests.csproj

๐Ÿ“„ License

MIT License

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 316 9/15/2025
1.0.3 278 9/15/2025
1.0.2 122 9/12/2025
1.0.1 122 9/12/2025