VL.Messaging.RabbitMQ 1.1.4

dotnet add package VL.Messaging.RabbitMQ --version 1.1.4
NuGet\Install-Package VL.Messaging.RabbitMQ -Version 1.1.4
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="VL.Messaging.RabbitMQ" Version="1.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VL.Messaging.RabbitMQ --version 1.1.4
#r "nuget: VL.Messaging.RabbitMQ, 1.1.4"
#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 VL.Messaging.RabbitMQ as a Cake Addin
#addin nuget:?package=VL.Messaging.RabbitMQ&version=1.1.4

// Install VL.Messaging.RabbitMQ as a Cake Tool
#tool nuget:?package=VL.Messaging.RabbitMQ&version=1.1.4

RabbitMQ Messaging

A thin wrapper around RabbitMQ that simplifies and standardizes consuming/publishing messages.

Getting Started

  1. Install package VL.Messaging.RabbitMQ

    dotnet add package VL.Messaging.RabbitMQ
    
  2. Setup the messaging core

    builder.Services.AddRabbitMQMessaging(builder.Configuration);
    
  3. Setup a publisher and publish a message

    // Program.cs (DI Setup)
    builder.Services
        .AddRabbitMQMessaging(builder.Configuration)
        .AddMessagePublisher<FooMessage>("exchange", "routing-key");
    
    // FooMessage.cs (Create or reuse a concrete message type)
    public class FooMessage : Message { }
    
    // Use `IMessagePublisher<FooMessage>` and let DI provide a publisher instance
    publisher.PublishAsync(new FooMessage());
    
  4. Setup a handler and consume messages

    // Program.cs (DI Setup)
    builder.Services
        .AddRabbitMQMessaging(builder.Configuration)
        .AddMessageConsumer("queue", "exchange")
        .AddMessageHandler<FooMessage, FooMessageHandler>("routing-key");
    
    // FooMessage.cs (Create a concrete message type)
    public class FooMessage : Message { }
    
    // FooMessageHandler.cs (Create a concrete message handler)
    public class FooMessageHandler : MessageHandlerBase<FooMessage>
    {
        public override Task HandleAsync(FooMessage message, CancellationToken cancellationToken = default)
        {
            // Your implementation goes here
        }
    }
    

FAQ

  • How to set the expiration time for a certain message type?

    Provide MessagePublisherOptions with the desired expiration time to the message publisher configuration.

    var options = new MessagePublisherOptions
    {
        MessageExpiration = TimeSpan.FromSeconds(30)
    };
    
    builder.Services
        .AddRabbitMQMessaging(builder.Configuration)
        .AddMessagePublisher<FooMessage>("exchange", "routing-key", options);
    
  • How to set specific connection settings?

    A custom configuration for the RabbitMQ messaging system can be provided through the Microsoft configuration system. Here is a little example of how it's achieved with the appsettings.json config file.

    {
        // Omitted for brevity
        "Messaging.RabbitMQ": {
            "ConnectionSettings": {
                "HostName": "foo",
                "Port": 8888,
                "Username": "bar",
                "Password": "baz"
            }
        }
    }
    
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

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
1.1.4 117 12/22/2023
1.1.3 97 12/22/2023
1.1.2 89 12/22/2023
1.1.1 89 12/22/2023
1.0.1 107 12/20/2023
1.0.0 92 12/18/2023