EasilyNET.RabbitBus.AspNetCore
3.24.1103
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package EasilyNET.RabbitBus.AspNetCore --version 3.24.1103
NuGet\Install-Package EasilyNET.RabbitBus.AspNetCore -Version 3.24.1103
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="EasilyNET.RabbitBus.AspNetCore" Version="3.24.1103" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasilyNET.RabbitBus.AspNetCore --version 3.24.1103
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasilyNET.RabbitBus.AspNetCore, 3.24.1103"
#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.
// Install EasilyNET.RabbitBus.AspNetCore as a Cake Addin #addin nuget:?package=EasilyNET.RabbitBus.AspNetCore&version=3.24.1103 // Install EasilyNET.RabbitBus.AspNetCore as a Cake Tool #tool nuget:?package=EasilyNET.RabbitBus.AspNetCore&version=3.24.1103
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EasilyNET.RabbitBus.AspNetCore
- 支持延时队列,服务端需要启用 rabbitmq-delayed-message-exchange 插件
- 支持同一个消息被多个 Handler 消费
- 若是就是想写多个 Handler 但是又希望某些 Handler 不执行,可以在不需要的 Handler 上标记 [IgnoreHandler] 特性
- 添加 MessagePack 序列化选项,可通过 ESerializer.MessagePack 或 ESerializer.TextJson 进行切换.
如何使用
- 首先使用 Nuget 包管理工具添加依赖 EasilyNET.RabbitBus.AspNetCore
- 等待下载完成和同意开源协议后,即可使用本库.
- Step1.在 Program.cs 中配置消息总线
// 配置服务(亦可使用集群模式或者使用配置文件,或者环境变量.)
builder.Services.AddRabbitBus(c =>
{
c.Host = "192.168.2.110";
c.Port = 5672;
c.UserName = "username";
c.PassWord = "password";
c.PoolCount = (uint)Environment.ProcessorCount;
c.RetryCount = 5;
c.Serializer = ESerializer.MessagePack;
...
});
- Step2.接下来配置事件和事件处理器
/// <summary>
/// 测试消息类型,消息继承自 IEvent 或者 Event
/// </summary>
[Exchange("hoyo.test", EModel.Routing, "test", "orderqueue2")]
public class TestEvent : Event
{
/// <summary>
/// 消息
/// </summary>
public string Message { get; set; } = default!;
}
/// <summary>
/// 消息处理Handler
/// </summary>
public class TestEventHandler(ILogger<TestEventHandler> logger) : IEventHandler<TestEvent>
{
/// <summary>
/// 当消息到达的时候执行的Action
/// </summary>
/// <param name="event"></param>
/// <returns></returns>
public Task HandleAsync(TestEvent @event)
{
logger.LogInformation("TestEvent_{event}-----{date}", @event.Message, DateTime.Now);
return Task.CompletedTask;
}
}
/// <summary>
/// 若是存在同一个消息多个 Handler 实现,比如这里我们写了两个 Handler,那么发送一次消息这两个 Handler 均会执行.
/// </summary>
/// 若是不希望这个 Handler 执行可以标记
[IgnoreHandler]
public class TestEventHandlerSecond(ILogger<TestEventHandlerSecond> logger) : IEventHandler<TestEvent>
{
/// <summary>
/// 当消息到达的时候执行的Action
/// </summary>
/// <param name="event"></param>
/// <returns></returns>
public Task HandleAsync(TestEvent @event)
{
logger.LogInformation("TestEvent_{event}-----{date}", @event.Message, DateTime.Now);
return Task.CompletedTask;
}
}
- Step3.使用消息队列发送消息
private readonly IBus _ibus;
// 控制器构造函数伪代码
construct(IBus ibus){
_ibus = ibus;
}
/// <summary>
/// 创建一个延时消息,同时发送一个普通消息做对比
/// </summary>
[HttpPost("TTLTest")]
public async Task TTLTest()
{
var rand = new Random();
var ttl = rand.Next(1000, 10000);
var ttlobj = new DelayedMessageEvent() { Message = $"延迟{ttl}毫秒,当前时间{DateTime.Now:yyyy-MM-dd HH:mm:ss}" };
// 延时队列需要服务端安装延时队列插件.
await _ibus.Publish(ttlobj, (uint)ttl);
await _ibus.Publish(ttlobj);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- EasilyNET.RabbitBus.Core (>= 3.24.1103)
- MessagePack (>= 3.0.238-rc.1)
- Microsoft.Extensions.DependencyModel (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Resilience (>= 9.0.0-preview.9.24507.7)
- RabbitMQ.Client (>= 7.0.0-rc.14)
-
net9.0
- EasilyNET.RabbitBus.Core (>= 3.24.1103)
- MessagePack (>= 3.0.238-rc.1)
- Microsoft.Extensions.DependencyModel (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.Resilience (>= 9.0.0-preview.9.24507.7)
- RabbitMQ.Client (>= 7.0.0-rc.14)
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 |
---|---|---|
3.24.1119.31 | 32 | 11/18/2024 |
3.24.1115.143 | 25 | 11/15/2024 |
3.24.1113.100 | 34 | 11/13/2024 |
3.24.1112.125 | 96 | 11/12/2024 |
3.24.1107.140 | 31 | 11/7/2024 |
3.24.1107.54 | 31 | 11/7/2024 |
3.24.1107.34 | 32 | 11/7/2024 |
3.24.1105.111 | 40 | 11/5/2024 |
3.24.1103.31 | 41 | 11/2/2024 |
3.24.1103 | 38 | 11/2/2024 |
3.24.1031.135 | 36 | 10/31/2024 |
3.24.1031.112 | 35 | 10/31/2024 |
3.24.1031.104 | 37 | 10/31/2024 |
3.24.1029.142 | 40 | 10/29/2024 |
3.24.1025.30 | 136 | 10/24/2024 |
3.24.1022.142 | 30 | 10/22/2024 |
3.24.1018.204 | 98 | 10/18/2024 |
3.24.1018.175 | 91 | 10/18/2024 |
3.24.1018.166 | 92 | 10/18/2024 |
3.24.1018.93 | 95 | 10/18/2024 |
3.24.1017.42 | 45 | 10/16/2024 |
3.24.1016.161 | 47 | 10/16/2024 |
3.24.1015.231 | 47 | 10/15/2024 |
3.24.1015.14 | 49 | 10/14/2024 |
3.24.1012.114 | 43 | 10/12/2024 |
3.24.1009.115 | 48 | 10/9/2024 |
3.24.1008.160 | 44 | 10/8/2024 |
3.24.1008.133 | 42 | 10/8/2024 |
3.24.1007.185 | 45 | 10/7/2024 |
3.24.1003.33 | 49 | 10/2/2024 |
3.24.1002.162 | 50 | 10/2/2024 |
3.24.929.143 | 46 | 9/29/2024 |
3.24.929.141 | 46 | 9/29/2024 |
3.24.929.131 | 46 | 9/29/2024 |
3.24.929.122 | 50 | 9/29/2024 |
3.24.926.184 | 47 | 9/26/2024 |
3.24.926.182 | 49 | 9/26/2024 |
3.24.926.175 | 52 | 9/26/2024 |
3.24.924.160 | 50 | 9/24/2024 |
3.24.924.133 | 59 | 9/24/2024 |
3.24.924.124 | 50 | 9/24/2024 |
3.24.924.10 | 52 | 9/23/2024 |
3.24.924.1 | 42 | 9/23/2024 |
3.24.923.234 | 44 | 9/23/2024 |
3.24.923.232 | 48 | 9/23/2024 |
3.24.923.155 | 47 | 9/23/2024 |
3.24.919.92 | 60 | 9/19/2024 |
3.24.914.125 | 51 | 9/14/2024 |
3.24.914.115 | 50 | 9/14/2024 |
3.24.914.111 | 53 | 9/14/2024 |
3.24.911.95 | 53 | 9/11/2024 |
3.24.908.215 | 47 | 9/8/2024 |
3.24.904.200 | 53 | 9/4/2024 |
3.24.828.163 | 61 | 8/28/2024 |
3.24.820.173 | 60 | 8/20/2024 |
3.24.814.92 | 71 | 8/14/2024 |
3.24.812.115 | 65 | 8/12/2024 |
3.24.802.100 | 42 | 8/2/2024 |
3.24.801.162 | 49 | 8/1/2024 |
3.24.801.160 | 49 | 8/1/2024 |
3.24.801.155 | 51 | 8/1/2024 |
3.24.730.164 | 40 | 7/30/2024 |
3.24.730.91 | 37 | 7/30/2024 |
3.24.724.91 | 46 | 7/24/2024 |
3.24.718.105 | 68 | 7/18/2024 |
3.24.716.95 | 54 | 7/16/2024 |
3.24.712.94 | 49 | 7/12/2024 |
3.24.710.14 | 52 | 7/9/2024 |
3.24.709.105 | 57 | 7/9/2024 |
3.24.704.94 | 54 | 7/4/2024 |
3.24.701.90 | 52 | 7/1/2024 |
3.24.628.114 | 59 | 6/28/2024 |
3.24.627.145 | 51 | 6/27/2024 |
3.24.620.160 | 60 | 6/20/2024 |
3.24.613.115 | 56 | 6/13/2024 |
3.24.612.95 | 61 | 6/12/2024 |
3.24.528.90 | 58 | 5/28/2024 |
3.24.522.84 | 71 | 5/22/2024 |
3.24.512.213 | 55 | 5/12/2024 |
3.24.508.112 | 70 | 5/8/2024 |
2.2024.428.71 | 69 | 4/28/2024 |
2.2024.427.1128 | 69 | 4/27/2024 |
2.2.72 | 79 | 4/14/2024 |
2.2.71 | 58 | 4/12/2024 |
2.2.8 | 59 | 4/26/2024 |
2.2.6 | 58 | 4/10/2024 |
2.2.5 | 80 | 3/26/2024 |
2.2.4 | 77 | 3/25/2024 |
2.2.3 | 66 | 3/24/2024 |
2.2.2 | 73 | 3/21/2024 |
2.2.1 | 75 | 3/20/2024 |
2.2.0 | 81 | 3/13/2024 |
2.1.9 | 71 | 2/21/2024 |
2.1.8 | 74 | 2/18/2024 |
2.1.7 | 75 | 2/16/2024 |
2.1.6 | 88 | 2/14/2024 |
2.1.5 | 65 | 2/14/2024 |
2.1.4 | 90 | 2/9/2024 |
2.1.3 | 68 | 2/8/2024 |
2.1.2 | 102 | 2/5/2024 |
2.1.1.2 | 151 | 12/26/2023 |
2.1.1.1 | 87 | 12/26/2023 |
2.1.1 | 85 | 12/25/2023 |
2.1.0 | 103 | 12/17/2023 |
2.0.11 | 136 | 12/6/2023 |
2.0.1 | 131 | 11/15/2023 |
2.0.0 | 87 | 11/14/2023 |
1.9.1 | 104 | 11/1/2023 |
1.9.0 | 97 | 10/19/2023 |
1.9.0-preview2 | 200 | 10/12/2023 |
1.9.0-preview1 | 77 | 10/12/2023 |
1.8.9 | 123 | 10/11/2023 |
1.8.8 | 117 | 10/11/2023 |
1.8.7-rc2 | 83 | 9/21/2023 |
1.8.7-rc1 | 79 | 9/12/2023 |
1.8.6 | 115 | 8/31/2023 |
1.8.5 | 514 | 8/25/2023 |
1.8.4 | 107 | 8/24/2023 |
1.8.3 | 103 | 8/23/2023 |
1.8.2 | 147 | 8/22/2023 |
1.8.1 | 108 | 8/18/2023 |
1.8.0 | 108 | 8/15/2023 |
1.7.9 | 132 | 8/11/2023 |
1.7.8 | 105 | 8/11/2023 |
1.7.7 | 118 | 8/10/2023 |
1.7.6 | 114 | 8/9/2023 |
1.7.5 | 136 | 8/9/2023 |
1.7.4 | 154 | 8/3/2023 |
1.7.3 | 121 | 8/1/2023 |
1.7.2 | 119 | 7/31/2023 |
1.7.1 | 112 | 7/27/2023 |
1.7.0 | 119 | 7/25/2023 |
1.6.9 | 120 | 7/25/2023 |
1.6.8 | 110 | 7/24/2023 |
1.6.7 | 124 | 7/20/2023 |
1.6.6 | 118 | 7/19/2023 |
1.6.5 | 88 | 7/19/2023 |
1.6.4 | 110 | 7/17/2023 |
1.6.3 | 106 | 7/17/2023 |
1.6.2 | 123 | 7/12/2023 |
1.6.1 | 124 | 6/30/2023 |
1.6.0 | 103 | 6/30/2023 |