Toosame.EventBus.RabbitMQ
2.0.1
dotnet add package Toosame.EventBus.RabbitMQ --version 2.0.1
NuGet\Install-Package Toosame.EventBus.RabbitMQ -Version 2.0.1
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="Toosame.EventBus.RabbitMQ" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Toosame.EventBus.RabbitMQ --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Toosame.EventBus.RabbitMQ, 2.0.1"
#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.
// Install Toosame.EventBus.RabbitMQ as a Cake Addin #addin nuget:?package=Toosame.EventBus.RabbitMQ&version=2.0.1 // Install Toosame.EventBus.RabbitMQ as a Cake Tool #tool nuget:?package=Toosame.EventBus.RabbitMQ&version=2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Toosame.EventBus
An Event Bus Based on RabbitMQ, whose core code is from eShopOnContainers, I just pulled it out and made some extensions, fixes and improvements.
I currently only use it for microservices. If your project has only one ASP. NET Core project, then it may not be suitable for you.
Install from Nuget.org
PM> Install-Package Toosame.EventBus.RabbitMQ -Version 2.0.1
Using (Publish Event)
- Add Event
- Add Event Handler
- Publish Event in Controller
1. Add Event
Create YourEvent.cs
public record class YourEvent : IntegrationEvent
{
public string Name { get; set; }
public int Age { get; set; }
}
2. Add Event Handler
Create YourEventHandler.cs
public class YourEventHandler : IIntegrationEventHandler<YourEvent>
{
private readonly IConfiguration _configuration;
public YourEventHandler(IConfiguration configuration){
//I'm just telling you that you can also use Dependency Injection Services.
_configuration = configuration;
}
public Task Handle(YourEvent @event)
{
//you can get @event.Name
//you can get @event.Age
//Do something...
return Task.CompletedTask;
}
}
3. Publish Event in Controller
public class HomeController : ControllerBase
{
private readonly IEventBus _eventBus;
public YourEventHandler(IEventBus eventBus){
_eventBus = eventBus;
}
[HttpGet]
public IAcionResult Index(){
_eventBus.Publish(new YourEvent(){
Name: "my name",
Age: 22
})
}
}
Setup (ASP.NET Core 6.0)
You can subscribe to the event you just created here.
- Configure appsettings.json
- Setup on
Program.cs
1. Configure appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"RabbitMQ": {
"EventBusConnection": "<yourRabbitMqHost>[:port(default 5672)]",
"EventBusUserName": "<rabbitMqUserName>",
"EventBusPassword": "<rabbitMqPassword>",
"EventBusRetryCount": 5,
"EventBusBrokeName": "<rabbitMqExchangeName>",
"SubscriptionClientName": "<queueName>" //It's better to have different microservices with different names
}
}
2.Setup on Program.cs
builder.Services.AddEventBus(Configuration.GetSection("RabbitMQ").Get<RabbitMQOption>(),
eventHandlers =>
{
eventHandlers.AddEventHandler<YourEventHandler1>();
eventHandlers.AddEventHandler<YourEventHandler2>();
});
app.UseEventBus(eventBus =>
{
eventBus.Subscribe<YourEvent1, YourEventHandler1>();
eventBus.Subscribe<YourEvent2, YourEventHandler2>();
});
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
- Polly (>= 7.2.3)
- RabbitMQ.Client (>= 6.5.0)
- System.Text.Json (>= 7.0.2)
- Toosame.EventBus (>= 2.0.1)
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 | |
---|---|---|---|
2.0.1 | 215 | 4/2/2023 | |
2.0.0 | 344 | 11/11/2022 | |
1.1.9 | 363 | 12/10/2021 | |
1.1.8 | 398 | 4/21/2021 | |
1.1.7 | 629 | 8/5/2020 | |
1.1.6 | 493 | 6/23/2020 | |
1.1.5 | 1,064 | 10/4/2019 | |
1.1.3 | 643 | 9/29/2019 | |
1.1.2 | 667 | 8/10/2019 | |
1.1.1 | 549 | 8/10/2019 | |
1.1.0 | 550 | 8/10/2019 | |
1.0.9 | 798 | 7/8/2019 | |
1.0.8 | 529 | 7/8/2019 | |
1.0.7 | 733 | 6/21/2019 | |
1.0.6 | 564 | 6/20/2019 | |
1.0.5 | 529 | 6/20/2019 | |
1.0.4 | 524 | 6/20/2019 | |
1.0.3 | 681 | 5/30/2019 | |
1.0.2 | 535 | 5/29/2019 | |
1.0.1 | 515 | 5/29/2019 | |
1.0.0 | 640 | 5/11/2019 |