Galosys.Foundation.RocketMQ.Client
26.8.5.1
dotnet add package Galosys.Foundation.RocketMQ.Client --version 26.8.5.1
NuGet\Install-Package Galosys.Foundation.RocketMQ.Client -Version 26.8.5.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="Galosys.Foundation.RocketMQ.Client" Version="26.8.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Galosys.Foundation.RocketMQ.Client" Version="26.8.5.1" />
<PackageReference Include="Galosys.Foundation.RocketMQ.Client" />
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 Galosys.Foundation.RocketMQ.Client --version 26.8.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Galosys.Foundation.RocketMQ.Client, 26.8.5.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 Galosys.Foundation.RocketMQ.Client@26.8.5.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=Galosys.Foundation.RocketMQ.Client&version=26.8.5.1
#tool nuget:?package=Galosys.Foundation.RocketMQ.Client&version=26.8.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Galosys.Foundation.RocketMQ.Client
成熟度: 🟡 预览 — 基于 Apache rocketmq.client 5.x,核心功能完成
基于 Apache rocketmq.client 5.x 的 RocketMQ 客户端实现,使用 gRPC 协议与 5.x Proxy 通信。
端口变更: 5.2+ Proxy 默认 gRPC 端口从 8081 改为 8080,5.5 版本请使用 8080。
前置条件
- RocketMQ 5.x 且已启动 Proxy 组件(gRPC 协议,5.2+ 默认端口 8080,≤5.1 为 8081)
- 不兼容 4.x NameServer 直连模式(如需 4.x 兼容请使用
Galosys.Foundation.NewLife.RocketMQ)
安装
<PackageReference Include="Galosys.Foundation.RocketMQ.Client" Version="x.x.x" />
快速开始
1. 最小配置
{
"RocketMQ": {
"Endpoints": "localhost:8080"
}
}
注意: Apache 5.x 客户端使用 gRPC 端口(5.2+ 默认 8080,≤5.1 为 8081),不是 NameServer 的 9876。
2. 注册服务
services.AddRocketMQClient(configuration);
3. 发送消息
发送侧无泛型约束,支持任意 POCO 类型:
using Galosys.Foundation.RocketMQ.Abstractions;
public class OrderCreatedEvent
{
public string OrderNo { get; set; }
}
public class OrderService
{
private readonly RmqTemplate _template;
public OrderService(RmqTemplate template) => _template = template;
public async Task SendAsync() =>
await _template.SendAsync("order_created", new OrderCreatedEvent { OrderNo = "ORD001" });
public async Task SendDelayAsync() =>
await _template.SendAsync("order_created", new OrderCreatedEvent { OrderNo = "ORD001" }, delaySeconds: 30);
}
4. 消费消息
using Galosys.Foundation.RocketMQ.Abstractions;
[Handler]
public class OrderHandler : IMessageHandler<OrderCreatedMessage>
{
[RmqHandler("order_created")]
public Task<bool> HandleAsync(OrderCreatedMessage msg) => Task.FromResult(true);
}
完整配置
{
"RocketMQ": {
"Endpoints": "localhost:8080",
"AccessKey": null,
"SecretKey": null,
"Ssl": false,
"RequestTimeout": 10,
"ConsumerGroup": "my_service",
"Handlers": {
"order_created": {
"PrefetchCount": 16,
"Concurrency": 4,
"MaxRetryCount": 3,
"RetryBaseDelayMs": 1000
}
}
}
}
详细配置说明参见 Abstractions README。
实现细节
| 组件 | 说明 |
|---|---|
ApacheRmqPublisher |
基于 Producer.Builder,按 Topic 缓存 Producer 实例 |
ApacheRmqConsumer |
基于 SimpleConsumer.Builder,Receive 长轮询 + SemaphoreSlim 并发控制 |
ApacheRmqTemplate |
组合 Publisher + Consumer 的统一门面 |
ApacheRmqBootstrapper |
IHostedLifecycleService,启动时扫描 [RmqHandler],关闭时释放资源 |
ApacheRmqHealthCheck |
尝试创建临时 Producer 验证连通性 |
ApacheRmqTracing |
OTel ActivitySource,Span 带 Topic/Tag/ConsumerGroup 标签 |
ApacheRmqMeter |
6 个 Counter/Histogram 指标 |
RmqConfigBuilder |
内部帮助类,从 RmqOptions 实时构建 ClientConfig |
| 配置来源 | Consumer/Publisher/HealthCheck 创建 SDK 对象时通过 IOptionsMonitor<RmqOptions> 实时读取配置,⚠️ 不再依赖 DI 中冻结的 ClientConfig 单例 |
依赖
Galosys.Foundation.RocketMQ.Abstractionsrocketmq.client5.1.0
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Galosys.Foundation.RocketMQ.Abstractions (>= 26.8.5.1)
- rocketmq.client (>= 5.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.8.5.1 | 20 | 8/5/2026 |
| 26.8.4.1 | 43 | 8/4/2026 |
| 26.8.3.1 | 44 | 8/3/2026 |
| 26.7.31.1 | 47 | 7/31/2026 |
| 26.7.30.1 | 74 | 7/30/2026 |
| 26.7.29.1 | 93 | 7/29/2026 |
| 26.7.28.1 | 85 | 7/28/2026 |
| 26.7.26.2 | 94 | 7/26/2026 |
| 26.7.26.1 | 87 | 7/25/2026 |
| 26.7.25.1 | 87 | 7/25/2026 |
| 26.7.24.2 | 88 | 7/24/2026 |
| 26.7.24.1 | 84 | 7/24/2026 |
| 26.7.22.1 | 96 | 7/23/2026 |
| 26.7.21.1 | 95 | 7/22/2026 |
| 26.7.20.2 | 84 | 7/20/2026 |
| 26.7.20.1 | 90 | 7/20/2026 |
| 26.7.19.3 | 83 | 7/19/2026 |
| 26.7.19.2 | 89 | 7/19/2026 |
| 26.7.19.1 | 85 | 7/19/2026 |
| 26.7.18.2 | 89 | 7/18/2026 |
Loading failed