RabbitRpc.Client
4.0.1
dotnet add package RabbitRpc.Client --version 4.0.1
NuGet\Install-Package RabbitRpc.Client -Version 4.0.1
<PackageReference Include="RabbitRpc.Client" Version="4.0.1" />
<PackageVersion Include="RabbitRpc.Client" Version="4.0.1" />
<PackageReference Include="RabbitRpc.Client" />
paket add RabbitRpc.Client --version 4.0.1
#r "nuget: RabbitRpc.Client, 4.0.1"
#:package RabbitRpc.Client@4.0.1
#addin nuget:?package=RabbitRpc.Client&version=4.0.1
#tool nuget:?package=RabbitRpc.Client&version=4.0.1
RabbitRpc.Client
Client-side library for RabbitMQ RPC on .NET 10. Define a contract interface, register a typed proxy in DI, and call its methods like any local service — the request is sent via RabbitMQ and the response is awaited from the server.
v4.0 introduces a pluggable serialization layer — you must pair this package with one of the adapter packages:
RabbitRpc.Serialization.XPacketRpc— binary, source-gen, recommended default.RabbitRpc.Serialization.MemoryPack— binary, MemoryPack-backed; works with vendor DTOs without[MemoryPackable].RabbitRpc.Serialization.SystemTextJson— JSON, for debugging and v3 wire compatibility.
Installation
dotnet add package RabbitRpc.Client
dotnet add package RabbitRpc.Serialization.XPacketRpc # or .MemoryPack / .SystemTextJson
Pack for NuGet
dotnet pack -c Release
Configuration
Add the RabbitMqRpc section to appsettings.json:
{
"RabbitMqRpc": {
"HostName": "localhost",
"Port": 5672,
"VirtualHost": "/",
"UserName": "guest",
"Password": "guest",
"ClientProvidedName": "rabbit-rpc-client",
"RoutePrefix": "rpc.",
"PrefetchCount": 1,
"DefaultTimeoutSeconds": 30
}
}
Usage
Define a contract interface (shared between client and server, no CancellationToken parameters — timeouts live on the transport):
public interface IMathService
{
Task<int> AddAsync(int a, int b);
Task<UserDto> GetUserAsync(Guid id);
}
public sealed record UserDto(Guid Id, string Name);
Register the client and a typed proxy in Program.cs:
using AsbtCore.Broker.Client;
using AsbtCore.Broker.Serialization.XPacketRpc; // pick one adapter
var builder = Host.CreateApplicationBuilder(args);
builder.Services
.AddRabbitRpcClient(builder.Configuration) // returns RpcClientBuilder
.UseXPacketRpcSerialization() // required in v4.0
.AddProxy<IMathService>(); // was AddRpcProxy<T> in v3
Inject and use the proxy like any other DI service:
public sealed class CalculatorController(IMathService math) : ControllerBase
{
[HttpGet("add")]
public Task<int> Add(int a, int b) => math.AddAsync(a, b);
}
The per-call timeout defaults to RpcOptions.DefaultTimeoutSeconds; expired calls surface as TaskCanceledException. Server-side exceptions arrive as RpcRemoteException with RemoteCode / RemoteExceptionType / RemoteDetails populated.
Migration v3.x → v4.0
| Was (v3.x) | Now (v4.0) |
|---|---|
AddRabbitRpcClient(cfg) returns IServiceCollection |
returns RpcClientBuilder |
services.AddRpcProxy<T>() extension |
builder.AddProxy<T>() on RpcClientBuilder |
| Default JSON wired automatically | Adapter package + .UseXxxSerialization() is required |
JsonElement payload in RpcRequest |
ReadOnlyMemory<byte> (only matters for custom transports) |
See the repo migration guide for the full break list.
See Also
- RabbitRpc.Server — server-side library that hosts RPC implementations.
- RabbitRpc.Serialization.XPacketRpc — binary adapter (default since v4.0).
- RabbitRpc.Serialization.MemoryPack — MemoryPack binary adapter with reflection-friendly DTO discovery.
- RabbitRpc.Serialization.SystemTextJson — JSON adapter for v3 wire compatibility.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.8)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.8)
- RabbitMQ.Client (>= 7.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v4.0.1 — Binary serialization. MINOR UPDATE.
- Wire format is incompatible with v3.x. Roll forward client and server together.
- A serialization adapter package is now REQUIRED: install either
RabbitRpc.Serialization.XPacketRpc (binary, default) or
RabbitRpc.Serialization.SystemTextJson (JSON, drop-in v3 compat shape).
- DI now requires '.UseXPacketRpcSerialization()' / '.UseJsonRpcSerialization()' on
the builder returned by 'AddRabbitRpcClient(cfg)'. Startup throws if missing.
- 'AddRabbitRpcClient(cfg)' returns 'RpcClientBuilder'. Proxies register via
'.AddProxy<T>()' (previously '.AddRpcProxy<T>()').
- 'RpcRequest.Arguments[i].Payload' / 'RpcResponse.Result' changed from
'JsonElement' to 'ReadOnlyMemory<byte>'.
- 'IRpcSerializer' surface widened to four methods. Custom implementations must update.
See README "Migration v3.1 → v4.0".