![]() |
VOOZH | about |
dotnet add package Galosys.Foundation.NewLife.RocketMQ --version 26.5.20.1
NuGet\Install-Package Galosys.Foundation.NewLife.RocketMQ -Version 26.5.20.1
<PackageReference Include="Galosys.Foundation.NewLife.RocketMQ" Version="26.5.20.1" />
<PackageVersion Include="Galosys.Foundation.NewLife.RocketMQ" Version="26.5.20.1" />Directory.Packages.props
<PackageReference Include="Galosys.Foundation.NewLife.RocketMQ" />Project file
paket add Galosys.Foundation.NewLife.RocketMQ --version 26.5.20.1
#r "nuget: Galosys.Foundation.NewLife.RocketMQ, 26.5.20.1"
#:package Galosys.Foundation.NewLife.RocketMQ@26.5.20.1
#addin nuget:?package=Galosys.Foundation.NewLife.RocketMQ&version=26.5.20.1Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.NewLife.RocketMQ&version=26.5.20.1Install as a Cake Tool
成熟度: 🟡 预览 — 基于 NewLife.RocketMQ 3.0,核心功能完成
基于 NewLife.RocketMQ 的 RocketMQ 客户端实现,支持 Remoting + gRPC 双协议,兼容 RocketMQ 4.x 和 5.x。
| 特性 | Apache rocketmq.client 5.x | NewLife.RocketMQ |
|---|---|---|
| 协议 | gRPC(仅 5.x Proxy) | Remoting + gRPC(双协议) |
| 兼容 4.x | ❌ | ✅ |
| 兼容 5.x | ✅ | ✅ |
| NuGet 维护 | 缓慢(最新 5.1.0, 2023.3) | 活跃(2026.3) |
| 延迟消息 | DeliveryTimestamp | 18 级预设延迟 |
<PackageReference Include="Galosys.Foundation.NewLife.RocketMQ" Version="x.x.x" />
{
"RocketMQ": {
"Endpoints": "localhost:9876"
}
}
NewLife 实现连接 NameServer(默认 9876),与 Apache 实现连接 Proxy(8081)不同。
services.AddRocketMQ(configuration);
using Galosys.Foundation.RocketMQ.Abstractions;
public class OrderService
{
private readonly RmqTemplate _template;
public OrderService(RmqTemplate template) => _template = template;
public async Task SendAsync() =>
await _template.SendAsync("order_created", new OrderCreatedMessage { OrderNo = "ORD001" });
public async Task SendDelayAsync() =>
await _template.SendAsync("order_created", new OrderCreatedMessage { OrderNo = "ORD001" }, delaySeconds: 30);
}
延迟消息自动映射到 RocketMQ 18 级预设延迟等级(1s/5s/10s/30s/1m/2m/.../2h)。
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:9876",
"AccessKey": null,
"SecretKey": null,
"ConsumerGroup": "my_service",
"Handlers": {
"order_created": {
"PrefetchCount": 16,
"Concurrency": 4,
"MaxRetryCount": 3,
"RetryBaseDelayMs": 1000
}
}
}
}
详细配置说明参见 。
| 组件 | 说明 |
|---|---|
NewLifeRmqPublisher |
基于 NewLife.RocketMQ.Producer,按 Topic 缓存,延迟消息映射 DelayTimeLevels |
NewLifeRmqConsumer |
基于 NewLife.RocketMQ.Consumer,OnConsume 回调,SemaphoreSlim 并发控制 |
NewLifeRmqTemplate |
组合 Publisher + Consumer 的统一门面 |
NewLifeRmqBootstrapper |
IHostedLifecycleService,启动时扫描 [RmqHandler],关闭时释放资源 |
NewLifeRmqHealthCheck |
检查 Endpoints 配置是否有效 |
NewLifeRmqTracing |
OTel ActivitySource,Span 带 Topic/Tag/ConsumerGroup 标签 |
NewLifeRmqMeter |
6 个 Counter/Histogram 指标 |
从 Apache 实现切换到 NewLife 实现,业务代码无需任何修改:
<PackageReference Include="Galosys.Foundation.RocketMQ.Client" Version="x.x.x" />
<PackageReference Include="Galosys.Foundation.NewLife.RocketMQ" Version="x.x.x" />
同时将 Endpoints 从 Proxy 地址(如 localhost:8081)改为 NameServer 地址(如 localhost:9876)。
Galosys.Foundation.RocketMQ.AbstractionsNewLife.RocketMQ 3.0(含 NewLife.Core)| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.5.20.1 | 99 | 5/20/2026 |
| 26.5.19.1 | 99 | 5/19/2026 |
| 26.5.18.1 | 103 | 5/18/2026 |
| 26.5.15.1 | 103 | 5/15/2026 |
| 26.5.12.3 | 75 | 5/12/2026 |
| 26.5.12.2 | 98 | 5/12/2026 |
| 26.4.27.1-rc1 | 98 | 4/26/2026 |
| 26.4.25.1-rc1 | 99 | 4/25/2026 |
| 26.4.22.2-rc7 | 103 | 4/22/2026 |
| 26.4.22.2-rc6 | 94 | 4/22/2026 |
| 26.4.22.2-rc4 | 93 | 4/22/2026 |