Marquitos.Events.Abstractions
1.2.6
dotnet add package Marquitos.Events.Abstractions --version 1.2.6
NuGet\Install-Package Marquitos.Events.Abstractions -Version 1.2.6
<PackageReference Include="Marquitos.Events.Abstractions" Version="1.2.6" />
paket add Marquitos.Events.Abstractions --version 1.2.6
#r "nuget: Marquitos.Events.Abstractions, 1.2.6"
// Install Marquitos.Events.Abstractions as a Cake Addin #addin nuget:?package=Marquitos.Events.Abstractions&version=1.2.6 // Install Marquitos.Events.Abstractions as a Cake Tool #tool nuget:?package=Marquitos.Events.Abstractions&version=1.2.6
Marquitos.Events
A simple event system in top of RabbitMQ using EasyNetQ for AspNetCore applications.
Usage
To notify an event, first create a class that implements the IEvent interface.
// Your event class
public class ExampleCreated : IEvent
{
/// <summary>
/// The example name just created
/// </summary>
public string ExampleName { get; set; } = "My Example";
}
Then inject IEventService to your service and call NotifyAsync to notify your event.
// Your Service class that notifies events
public class ExampleService
{
private readonly IEventService _eventService;
public WeatherForecastController(IEventService eventService)
{
_eventService = eventService;
}
public async Task CreateExampleAsync(string name, CancellationToken cancellationToken = default)
{
// call repository to register the example name
// then notify your event to RabbitMQ
await _eventService.NotifyAsync(new ExampleCreated() { ExampleName = name });
}
}
To consume an event create an event consumer. First create a class that descends of EventConsumer.
public class ExampleConsumer : EventConsumer<ExampleCreated>
{
public override async Task HandleMessageAsync(ExampleCreated message, CancellationToken cancellationToken = default)
{
Console.WriteLine("Received an message!");
await Task.CompletedTask;
}
}
Then register the RabbitMQ Consumer Service Engine and the Event Consumer on your services configuration.
...
// Register the RabbitMQ connections string
builder.Services.AddRabbitMQConnectionWithSystemTextJson(builder.Configuration.GetConnectionString("RabbitConnection"));
// Register the Event Service to notify events
builder.Services.AddRabbitMQEventService();
// Register the Consumer Service Engine
builder.Services.AddRabbitMQConsumerService();
// Register your Consumer
builder.Services.AddRabbitMQEventConsumer<ExampleConsumer, ExampleCreated>((sp, o) =>
{
// For example add two retry options
o.Retries = new[] { 0.5, 1 }; // 30s and 1min
o.IsEnabled = true;
});
...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Marquitos.Events.Abstractions:
Package | Downloads |
---|---|
Marquitos.Events.RabbitMQ
A simple event system in top of RabbitMQ using EasyNetQ for AspNetCore applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.