EBCEYS.RabbitMQ.Server.MappedService 1.3.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package EBCEYS.RabbitMQ.Server.MappedService --version 1.3.1
                    
NuGet\Install-Package EBCEYS.RabbitMQ.Server.MappedService -Version 1.3.1
                    
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="EBCEYS.RabbitMQ.Server.MappedService" Version="1.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EBCEYS.RabbitMQ.Server.MappedService" Version="1.3.1" />
                    
Directory.Packages.props
<PackageReference Include="EBCEYS.RabbitMQ.Server.MappedService" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EBCEYS.RabbitMQ.Server.MappedService --version 1.3.1
                    
#r "nuget: EBCEYS.RabbitMQ.Server.MappedService, 1.3.1"
                    
#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.
#:package EBCEYS.RabbitMQ.Server.MappedService@1.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EBCEYS.RabbitMQ.Server.MappedService&version=1.3.1
                    
Install as a Cake Addin
#tool nuget:?package=EBCEYS.RabbitMQ.Server.MappedService&version=1.3.1
                    
Install as a Cake Tool

EBCEYS.RabbitMQ

.NET

Описание

Библиотека для работы с брокером сообщений RabbitMQ.

EBCEYS.RabbitMQ.Server.MappedService.RabbitMQServer

Реализация consumer-a как IHostedService.

Стоит отметить что в данном случае consumer всегда будет асинхронный.

EBCEYS.RabbitMQ.Server.MappedService.RabbitMQMappedServer

Попытка реализации сервиса consumer-a через контроллеры (а-ля ControllerBase для http).

Методы контроллера должны быть асинхронными.

Пример конфигурации:
configBuilder = new();
configBuilder.AddConnectionFactory(new()
{
    HostName = "Kuznetsovy-Server",
    UserName = "ebcey1",
    Password = "123"
});
configBuilder.AddQueueConfiguration(new("ExampleQueue", autoDelete: true));
RabbitMQConfiguration config = configBuilder.Build();
IHost host = Host.CreateDefaultBuilder(args)
    .UseNLog()
    .ConfigureLogging(log =>
    {
        log.AddNLog("nlog.config");
    })
    .ConfigureServices(services =>
    {
        services.AddRabbitMQController<ExampleController>();

        services.AddRabbitMQMappedServer(config);
    })
    .Build();
host.Run();

EBCEYS.RabbitMQ.Client

Реализация publisher-a для работы с брокером сообщений RabbitMQ.

Через клиент, в зависимости от конфигурации, возможна отправка сообщений и "RPC" запросов.

Для отправки сообщений используется метод SendMessageAsync.

Для отправки "RPC" запросов используется метод SendRequestAsync.

EBCEYS.RabbitMQ.Server.MappedService.SmartController

Аналогичен RabbitMQControllerBase, только внутри себя содержит "сервер", принимающий сообщения из брокера.

Пример использования:

private static RabbitMQConfigurationBuilder? configBuilder;
public static void Main(string[] args)
{
    configBuilder = new();
    configBuilder.AddConnectionFactory(new()
    {
        HostName = "Kuznetsovy-Server",
        UserName = "ebcey1",
        Password = "123"
    });
    configBuilder.AddQueueConfiguration(new("ExampleQueue", autoDelete: true));

    Logger logger = LogManager.Setup().LoadConfigurationFromFile("nlog.config").GetCurrentClassLogger();

    IHost host = Host.CreateDefaultBuilder(args)
        .ConfigureServices(services =>
        {
            services.AddSmartRabbitMQController<TestController>(configBuilder.Build());
        })
        .UseNLog()
        .ConfigureLogging(log =>
        {
            log.ClearProviders();
            log.AddNLog("nlog.config");
        })
        .Build();

    host.Run();
}

internal class TestController : RabbitMQSmartControllerBase
{
    private readonly ILogger<TestController> logger;

    public TestController(ILogger<TestController> logger)
    {
        this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
    }
    [RabbitMQMethod("ExampleMethod")]
    public async Task<string> TestMethod2(string a, string b)
    {
        logger.LogInformation("TestMethod2 get command with args: a: {a}\tb: {b}", a, b);
        return await Task.FromResult(a + b);
    }
}

Изменения

v1.3.1

  1. Методы SendMessage и SendRequest у RabbitMQClient-a сделаны виртуальными чтобы их можно было замокать.
  2. Инициализация подключения к RabbitMQ теперь будет происходить на стадии запуска сервиса.

v1.3.0

  1. Добавлен новый тип контроллера RabbitMQSmartController. Данный контроллер содержит в себе сервер, принимающий сообщения из брокера сообщений и вызывающий методы, указанные внутри сообщения.
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 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.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on EBCEYS.RabbitMQ.Server.MappedService:

Package Downloads
Ebceys.Infrastructure

Package Description

Ebceys.Tests.Infrastructure

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.0 394 3/10/2026
1.6.0 323 8/31/2025
1.5.1 215 2/28/2025
1.5.0 196 2/28/2025
1.4.2 214 1/30/2025
1.4.1 184 1/24/2025
1.4.0 187 1/16/2025
1.3.1 321 8/8/2023
1.3.0 289 6/26/2023
1.2.0 379 3/14/2023
1.1.6 388 3/14/2023
1.1.5 369 3/14/2023
1.1.4 418 3/13/2023
1.1.3 405 3/5/2023
1.1.2 389 3/4/2023
1.1.1 384 3/4/2023
1.0.4 406 2/27/2023
1.0.3 403 2/26/2023
1.0.2 448 2/23/2023
1.0.0 428 2/23/2023
Loading failed