Mvp24Hours.Infrastructure.RabbitMQ 3.1.101

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

// Install Mvp24Hours.Infrastructure.RabbitMQ as a Cake Tool
#tool nuget:?package=Mvp24Hours.Infrastructure.RabbitMQ&version=3.1.101

Message Broker

Message Broker is software that allows applications, systems and services to communicate with each other and exchange information. What is a Message Broker?

RabbitMQ

Prerequisites

Add a configuration file to the project named "appsettings.json", as below:

{
  "Mvp24Hours": {
    "Brokers": {
      "RabbitMQ": {
        "HostName": "localhost",
        "Port": 6672,
        "UserName": "admin",
        "Password": "admin@123"
      }
    }
  }
}

Installation

/// Package Manager Console >
Install-Package Mvp24Hours.Infrastructure.RabbitMQ

Configuration

/// Startup.cs
services.AddScoped<CustomerProducer, CustomerProducer>();
services.AddScoped<CustomerConsumer, CustomerConsumer>();

Producer/Consumer Implementation

/// CustomerProducer.cs
public class CustomerProducer : MvpRabbitMQProducer
{
    public CustomerProducer()
        : base("RoutingKey") { }
}

/// CustomerService.cs // Save Method
producer.Publish(new CustomerDto
{
    Id = 99,
    Name = "Test 1",
    Active = true
});

/// CustomerConsumer.cs
public class CustomerConsumer : MvpRabbitMQConsumer<CustomerDto>
{
    public CustomerConsumer()
        : base("RoutingKey")
    {
    }

    public override Task Received(CustomerDto message)
    {
        Trace.WriteLine($"Received customer {message?.Name}");
        return Task.FromResult(false);
    }
} 

/// HostService.cs
var source = new CancellationTokenSource(TimeSpan.FromSeconds(5));
while (!source.IsCancellationRequested)
{
    var consumer = ServiceProviderHelper.GetService<CustomerConsumer>();
    consumer?.Consume();
}

Using Docker

// Command
docker run -d --name my-rabbit -p 5672:5672 -p 5673:5673 -p 15672:15672 rabbitmq:3-management

// Connect
[127.0.0.1:6379](amqp://guest:guest@localhost:5672)

Product 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. 
.NET Core netcoreapp3.1 is compatible. 
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
8.3.261 96 3/26/2024
8.2.102 108 2/9/2024
8.2.101 89 2/7/2024
4.1.191 107 1/19/2024
4.1.181 80 1/19/2024
3.12.262 139 12/26/2023
3.12.261 81 12/26/2023
3.12.221 89 12/22/2023
3.12.151 91 12/17/2023
3.6.221 752 6/22/2022
3.4.111 432 4/11/2022
3.2.241 436 2/24/2022
3.2.171 382 2/17/2022
3.2.151 406 2/15/2022
3.2.142 370 2/14/2022
3.2.141 407 2/14/2022
3.2.21 423 2/2/2022
3.1.243 399 1/25/2022
3.1.242 378 1/24/2022
3.1.241 398 1/24/2022
3.1.221 418 1/22/2022
3.1.201 391 1/20/2022
3.1.101 371 1/10/2022
2.12.291 247 12/29/2021
2.12.102 246 12/10/2021
2.12.101 255 12/10/2021
2.12.71 236 12/7/2021
2.11.241 4,278 11/24/2021