Marquitos.Events.RabbitMQ
1.2.6
dotnet add package Marquitos.Events.RabbitMQ --version 1.2.6
NuGet\Install-Package Marquitos.Events.RabbitMQ -Version 1.2.6
<PackageReference Include="Marquitos.Events.RabbitMQ" Version="1.2.6" />
paket add Marquitos.Events.RabbitMQ --version 1.2.6
#r "nuget: Marquitos.Events.RabbitMQ, 1.2.6"
// Install Marquitos.Events.RabbitMQ as a Cake Addin #addin nuget:?package=Marquitos.Events.RabbitMQ&version=1.2.6 // Install Marquitos.Events.RabbitMQ as a Cake Tool #tool nuget:?package=Marquitos.Events.RabbitMQ&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 | net6.0 is compatible. 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 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. 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. |
-
net6.0
- EasyNetQ (>= 7.8.0)
- EasyNetQ.DI.Microsoft (>= 7.8.0)
- EasyNetQ.Serialization.NewtonsoftJson (>= 7.8.0)
- EasyNetQ.Serialization.SystemTextJson (>= 7.8.0)
- Marquitos.Events.Abstractions (>= 1.2.6)
- Microsoft.Extensions.DependencyInjection (>= 6.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.4)
- System.Text.Json (>= 6.0.11)
-
net8.0
- EasyNetQ (>= 7.8.0)
- EasyNetQ.DI.Microsoft (>= 7.8.0)
- EasyNetQ.Serialization.NewtonsoftJson (>= 7.8.0)
- EasyNetQ.Serialization.SystemTextJson (>= 7.8.0)
- Marquitos.Events.Abstractions (>= 1.2.6)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Marquitos.Events.RabbitMQ:
Package | Downloads |
---|---|
Marquitos.Events.RabbitMQ.Endpoints
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.