NeoBus 1.4.2
dotnet add package NeoBus --version 1.4.2
NuGet\Install-Package NeoBus -Version 1.4.2
<PackageReference Include="NeoBus" Version="1.4.2" />
paket add NeoBus --version 1.4.2
#r "nuget: NeoBus, 1.4.2"
// Install NeoBus as a Cake Addin #addin nuget:?package=NeoBus&version=1.4.2 // Install NeoBus as a Cake Tool #tool nuget:?package=NeoBus&version=1.4.2
NeoBus
NeoBus is a powerful library that enables you to send commands, queries, and events using the CQRS pattern in .NET. It simplifies the implementation of distributed systems and event-driven architectures by seamlessly integrating with Kafka. If you find NeoBus helpful, please consider giving it a star ⭐ to show your support.
Installation
You can easily install NeoBus via NuGet Package Manager:
> Install-Package NeoBus
Configuration
To configure NeoBus, add the following settings to your appsettings.json
file and specify your Kafka server address:
"NeoBus": {
"Kafka": {
"Servers": ["localhost:9092"]
}
}
Registration
Incorporate NeoBus into your project by registering it in the Startup.cs
file within the ConfigureServices
method:
services.AddNeoBus(Assembly.GetExecutingAssembly());
Distributed Events (Kafka)
For distributed events using Kafka, register the necessary services as follows:
services.AddHostedService<KafkaEventSubscriberService<ProductAddedEventOnKafka, ProductAddedEventOnKafkaHandler>>();
services.AddSingleton<ProductAddedEventOnKafkaHandler>();
If you are using a version lower than 1.2.0, use the following code to register and manually register commands and queries:
services.AddNeoBus();
Registering Commands, Queries, and In-Memory Events
To register commands and queries, follow these steps:
Command and Query Handlers:
services.AddScoped<IRequestHandler<ProductAddCommand, CommandResult>, ProductAddCommandHandler>();
services.AddScoped<IRequestHandler<GetProductQuery, CommandResult>, GetProductQueryHandler>();
In-Memory Event Handlers:
services.AddScoped<INotificationHandler<ProductAddedEvent>, ProductAddedEventHandler>();
Sample Project
Explore a sample project that demonstrates how to use NeoBus:
Setting Up Kafka with Docker Compose
To run Kafka locally, follow these instructions:
- Install Docker on your local machine.
- Download the
docker-compose-kafka.yml
file from within the project solution. - Open your Terminal as an administrator.
- Navigate to the directory containing the
docker-compose-kafka.yml
file. - Run the following command:
docker-compose -f docker-compose-kafka.yml up
Now Kafka is up and running in a Docker container.
Learn More
For more information about NeoBus and its applications, consider reading the following articles:
- EventBus Application and Introduction of NeoBus Package
- کاربرد EventBus و معرفی پکیج NeoBus (Persian)
Feel free to explore these resources to enhance your understanding of NeoBus and its capabilities.
Product | Versions 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. |
-
net8.0
- Confluent.Kafka (>= 2.3.0)
- MediatR (>= 12.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Utf8Json (>= 1.3.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
upgrade to .NET 8.0