SwitchSoftware.Messaging.RPC.RabbitMQ 8.0.6

dotnet add package SwitchSoftware.Messaging.RPC.RabbitMQ --version 8.0.6
                    
NuGet\Install-Package SwitchSoftware.Messaging.RPC.RabbitMQ -Version 8.0.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="SwitchSoftware.Messaging.RPC.RabbitMQ" Version="8.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SwitchSoftware.Messaging.RPC.RabbitMQ" Version="8.0.6" />
                    
Directory.Packages.props
<PackageReference Include="SwitchSoftware.Messaging.RPC.RabbitMQ" />
                    
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 SwitchSoftware.Messaging.RPC.RabbitMQ --version 8.0.6
                    
#r "nuget: SwitchSoftware.Messaging.RPC.RabbitMQ, 8.0.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.
#:package SwitchSoftware.Messaging.RPC.RabbitMQ@8.0.6
                    
#: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=SwitchSoftware.Messaging.RPC.RabbitMQ&version=8.0.6
                    
Install as a Cake Addin
#tool nuget:?package=SwitchSoftware.Messaging.RPC.RabbitMQ&version=8.0.6
                    
Install as a Cake Tool

Switch Software RPC implementation for RabbitMQ

⚠️ Important: Versions 8.0.4 and 8.0.5 contain a channel-leak regression in RpcClient that causes RabbitMQ.Client.Exceptions.ChannelAllocationException (The connection cannot support any more channels) under sustained RPC load. Please upgrade to 8.0.6 or later. See the CHANGELOG for details.

Installation

nuget repo : https://www.nuget.org/packages/SwitchSoftware.Messaging.RPC.RabbitMQ

There are also versions for .net core 6.0 and 5.0

Usage

Instantatiate an RPCServer to listen on "myQueue" and handle requests in the handlerequest method:


    _rpcServer.Start();

    private async Task<string> handleRequest(string data)
    {
        //handle your request
        return $"Hello, you sent me {data}";
    }

You will need to pass an IConfiguration and ILogger instances as well.

Configuration

The server relies on the following app settings (adjust to your RabbitMQ instance):

"RabbitMqConnection": {
  "HostName": "localhost",
  "UserName": "guest",
  "Password": "guest",
  "VirtualHost": "/",
  "Port": "5672",
  "RPC_CLIENT_TIME_OUT_IN_MILLISECONDS": "60000"
}

Note: Port and RPC_CLIENT_TIME_OUT_IN_MILLISECONDS are optional. The default timeout is 45 000 ms.

⚠️ Breaking change from 8.0.3-alpha: The config key was renamed from Username to UserName (capital N). Update your appsettings.json accordingly.

RPC Client

To send a request to the server, instantiate an RPCClient through the RpcClientFactory and call the CallAsync method:

var rpcClientFactory = new RpcClientFactory(configuration, logger);
var rpcClient = rpcClientFactory.GetRpcClient();
var response = await rpcClient.CallAsync("testqueue", "Hello!");

The client also relies on the RabbitMqConnection app settings.

Starting in 8.0.4, failed messages are rejected with requeue: false instead of being re-enqueued. Configure a dead-letter exchange so those messages are not silently dropped:

"RabbitMqConnection": {
  "HostName": "localhost",
  "UserName": "guest",
  "Password": "guest",
  "VirtualHost": "/"
}

Declare the DLX on the RabbitMQ broker before starting the server:

rabbitmqadmin declare exchange name=dlx type=direct
rabbitmqadmin declare queue name=myQueue.failed
rabbitmqadmin declare binding source=dlx destination=myQueue.failed routing_key=myQueue

Then declare your server queue with the DLX argument:

// When constructing RpcServer the queue is declared internally.
// To attach a DLX, pre-declare the queue on the broker with:
//   x-dead-letter-exchange = dlx
//   x-dead-letter-routing-key = myQueue

Release Changes

  • Fixed ChannelAllocationException regression introduced in 8.0.4:
    • RpcClient no longer over-releases its concurrency semaphore when WaitAsync is cancelled, which previously allowed unbounded concurrent channel creation on the underlying connection.
    • RpcClient now cancels the reply-queue consumer (BasicCancel) before returning a channel to the pool, preventing accumulation of dead consumers and orphaned exclusive auto-delete reply queues on pooled channels.
  • Channel pooling behavior is preserved.

Version History

Version Notes
8.0.6 Fixes channel-allocation leak introduced in 8.0.4: corrected concurrency-semaphore release on cancellation and cancel reply-queue consumer before returning channel to pool
8.0.5 ⚠️ Deprecated — do not use. Channel leak causes ChannelAllocationException under load. Upgrade to 8.0.6.
8.0.4 ⚠️ Deprecated — do not use. Channel leak causes ChannelAllocationException under load. Upgrade to 8.0.6.
8.0.3-alpha Performance optimizations, channel pooling, .NET 8.0 support
8.0.2 Added out-of-the-box support for RabbitMQ round-robin dispatching
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.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
8.0.6 2,005 5/18/2026
8.0.5 900 5/13/2026
8.0.4 1,007 5/8/2026
8.0.4-beta 346 5/6/2026
8.0.3-alpha 868 2/13/2026
8.0.2 56,505 10/16/2024
8.0.2-alpha-3 173 10/15/2024
8.0.2-alpha-1 182 8/30/2024
8.0.1 4,825 8/30/2024
8.0.0 2,479 7/15/2024
7.0.3 5,953 1/11/2024
7.0.2 4,736 9/25/2023
7.0.1 749 11/25/2022
7.0.1-timeout.60 283 8/2/2023
7.0.0 510 11/9/2022
6.0.3 9,461 11/25/2022
6.0.2 1,032 8/10/2022
6.0.0 7,543 5/24/2022
5.0.0 635 5/24/2022
3.1.24 621 5/24/2022
Loading failed