Netrilo.Infrastructure.Common.Bus
1.0.2
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
<PackageReference Include="Netrilo.Infrastructure.Common.Bus" Version="1.0.2" />
<PackageVersion Include="Netrilo.Infrastructure.Common.Bus" Version="1.0.2" />
<PackageReference Include="Netrilo.Infrastructure.Common.Bus" />
paket add Netrilo.Infrastructure.Common.Bus --version 1.0.2
#r "nuget: Netrilo.Infrastructure.Common.Bus, 1.0.2"
#:package Netrilo.Infrastructure.Common.Bus@1.0.2
#addin nuget:?package=Netrilo.Infrastructure.Common.Bus&version=1.0.2
#tool nuget:?package=Netrilo.Infrastructure.Common.Bus&version=1.0.2
Netrilo.Infrastructure.Common.Bus
Part of the Netrilo.Infrastructure SDK
๐ฆ 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 | 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
- AutoMapper (>= 15.0.1)
- FluentValidation (>= 12.0.0)
- FluentValidation.AspNetCore (>= 11.3.1)
- MassTransit (>= 8.5.2)
- MassTransit.AspNetCore (>= 7.3.1)
- MassTransit.Azure.ServiceBus.Core (>= 8.5.2)
- MassTransit.Extensions.DependencyInjection (>= 7.3.1)
- MassTransit.RabbitMQ (>= 8.5.2)
- MediatR (>= 13.0.0)
- MessagePack (>= 3.1.4)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 9.0.9)
- Microsoft.Extensions.Configuration (>= 9.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.9)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.9)
- Microsoft.Extensions.DependencyInjection (>= 9.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.9)
- MongoDB.Driver (>= 3.4.3)
- Netrilo.Infrastructure.Common.Abstractions (>= 1.0.2)
- Polly (>= 8.6.3)
- RabbitMQ.Client (>= 7.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.