Oragon.RabbitMQ.Abstractions 0.0.6-beta

Prefix Reserved
This is a prerelease version of Oragon.RabbitMQ.Abstractions.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Oragon.RabbitMQ.Abstractions --version 0.0.6-beta                
NuGet\Install-Package Oragon.RabbitMQ.Abstractions -Version 0.0.6-beta                
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="Oragon.RabbitMQ.Abstractions" Version="0.0.6-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Oragon.RabbitMQ.Abstractions --version 0.0.6-beta                
#r "nuget: Oragon.RabbitMQ.Abstractions, 0.0.6-beta"                
#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 Oragon.RabbitMQ.Abstractions as a Cake Addin
#addin nuget:?package=Oragon.RabbitMQ.Abstractions&version=0.0.6-beta&prerelease

// Install Oragon.RabbitMQ.Abstractions as a Cake Tool
#tool nuget:?package=Oragon.RabbitMQ.Abstractions&version=0.0.6-beta&prerelease                

Card

Oragon.RabbitMQ

Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%) Reliability Rating Security Rating Technical Debt Maintainability Rating Vulnerabilities GitHub last commit

Official Release

NuGet Version

Others

GitHub Tag Latest GitHub Tag

GitHub Release Latest GitHub Release

MyGet Version Latest MyGet Package

Tech / Skill

C# .Net Visual Studio

Jenkins

Telegram 🇧🇷

Opinionated and Simplified Minimal APIs for Consuming Messages from RabbitMQ, Ensuring No Crucial Configurations Are Hidden.

What is Oragon.RabbitMQ?

Oragon.RabbitMQ provides everything you need to create resilient RabbitMQ consumers without the need to study numerous books and articles or introduce unknown risks to your environment.

If you have a service like this

public class BusinessService
{
    public async Task DoSomethingAsync(BusinessCommandOrEvent commandOrEvent)
    {
        ... business core ...
    }
}

You will create a RabbitMQ Consumers with this

Singleton
builder.Services.AddSingleton<BusinessService>();

builder.Services.AddSingleton<IAMQPSerializer, SystemTextJsonAMQPSerializer>();

builder.Services.MapQueue<BusinessService, BusinessCommandOrEvent>(config => config
    .WithDispatchInRootScope()    
    .WithAdapter((svc, msg) => svc.DoSomethingAsync(msg))
    .WithQueueName("events")
    .WithPrefetchCount(1)
);

Scoped
builder.Services.AddScoped<BusinessService>();

builder.Services.AddSingleton<IAMQPSerializer, SystemTextJsonAMQPSerializer>();

builder.Services.MapQueue<BusinessService, BusinessCommandOrEvent>(config => config
    .WithDispatchInChildScope()    
    .WithAdapter((svc, msg) => svc.DoSomethingAsync(msg))
    .WithQueueName("events")
    .WithPrefetchCount(1)
);

Scoped and Keyed Services, Same Type, Multiple Consumers, Using NewtonsoftAMQPSerializer
builder.Services.AddKeyedScoped<BusinessService>("key-of-service-1");
builder.Services.AddKeyedScoped("key-of-service-2", (sp, key) => new BusinessService(... custom dependencies ...));

builder.Services.AddSingleton<IAMQPSerializer, NewtonsoftAMQPSerializer>();

builder.Services.MapQueue<BusinessService, BusinessCommandOrEvent>(config => config
    .WithDispatchInChildScope()
    .WithKeyedService("key-of-service-1") 
    .WithAdapter((svc, msg) => svc.DoSomethingAsync(msg))
    .WithQueueName("events1")
    .WithPrefetchCount(1)
);

builder.Services.MapQueue<BusinessService, BusinessCommandOrEvent>(config => config
    .WithDispatchInChildScope()
    .WithKeyedService("key-of-service-2") 
    .WithAdapter((svc, msg) => svc.DoSomethingAsync(msg))
    .WithQueueName("events2")
    .WithPrefetchCount(1)
);

Concepts

Decoupling Business Logic from Infrastructure

This approach is designed to decouple RabbitMQ consumers from business logic, ensuring that business code remains unaware of the queue consumption context.

The result is incredibly simple, decoupled, agnostic, more reusable, and highly testable code.

Opinionated Design: Why?

This consumer is focused on creating a resilient consumer using manual acknowledgments.

  • The flow produces a BasicReject without requeue for serialization failures (e.g., incorrectly formatted messages), you will use dead-lettering to ensure these messages are not lost.
  • The flow produces a BasicNack with requeue for processing failures, allowing for message reprocessing.
  • Minimal API design style made without reflection
  • Extensible with support for custom serializers and encoders

RabbitMQ Tracing com OpenTelemetry

Full support for OpenTelemetry on publishing or consuming RabbitMQ messages.

<img src="./docs/playground.gif">

Refactored to use RabbitMQ.Client 7x (with IChannel instead IModel)

Stages and Requirements for Launch

  • Migrate Demo to Library Project
  • Core: Queue Consumer
  • Core: Rpc Queue Consumer
  • Core: Support Keyed Services
  • Core: Support of new design of RabbitMQ.Client
  • Create Samples
  • Create Docs
  • Automate Badges
  • Add SonarCloud
  • Code Coverage > 80%
  • Add CI/CD
  • Add Unit Tests
  • Add Integrated Tests with TestContainers
  • Test CI/CD Flow: MyGet Alpha Packages with Symbols
  • Test CI/CD Flow: MyGet Packages without Symbols
  • Test CI/CD Flow: Nuget Packages without Symbols
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Oragon.RabbitMQ.Abstractions:

Package Downloads
Oragon.RabbitMQ.Serializer.SystemTextJson

Implements JSON serialization for RabbitMQ using System.Text.Json. Leverage fast and modern serialization for efficient message handling in RabbitMQ consumers.

Oragon.RabbitMQ.Serializer.NewtonsoftJson

Implements JSON serialization for RabbitMQ using Newtonsoft.Json. Easily serialize and deserialize messages for effective communication in RabbitMQ consumers.

Oragon.RabbitMQ

Provides a minimal API for RabbitMQ consumers, designed for simplicity and resilience. Enhance message handling with streamlined configuration and robust performance.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.9-beta 63 10/19/2024
0.0.8-beta 37 8/2/2024
0.0.7-beta 60 6/22/2024
0.0.6-beta 61 6/6/2024
0.0.5-beta 55 6/5/2024