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                
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="Marquitos.Events.RabbitMQ" Version="1.2.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Marquitos.Events.RabbitMQ --version 1.2.6                
#r "nuget: Marquitos.Events.RabbitMQ, 1.2.6"                
#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 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                

NuGet Version

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
1.2.6 37 2/8/2025
1.2.5 41 2/6/2025
1.2.4 96 11/14/2024
1.2.3 1,092 10/20/2023
1.2.2 352 7/10/2023
1.2.1 303 4/19/2023
1.2.0 393 3/22/2023
1.1.0 292 2/20/2023
1.0.4 311 2/1/2023
1.0.3 286 1/31/2023
1.0.2 305 1/23/2023
1.0.1 281 1/23/2023
1.0.0 302 10/29/2022