EasilyNET.RabbitBus.AspNetCore 3.24.1125.181

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasilyNET.RabbitBus.AspNetCore --version 3.24.1125.181
                    
NuGet\Install-Package EasilyNET.RabbitBus.AspNetCore -Version 3.24.1125.181
                    
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.1125.181" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasilyNET.RabbitBus.AspNetCore" Version="3.24.1125.181" />
                    
Directory.Packages.props
<PackageReference Include="EasilyNET.RabbitBus.AspNetCore" />
                    
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 EasilyNET.RabbitBus.AspNetCore --version 3.24.1125.181
                    
#r "nuget: EasilyNET.RabbitBus.AspNetCore, 3.24.1125.181"
                    
#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.
#addin nuget:?package=EasilyNET.RabbitBus.AspNetCore&version=3.24.1125.181
                    
Install EasilyNET.RabbitBus.AspNetCore as a Cake Addin
#tool nuget:?package=EasilyNET.RabbitBus.AspNetCore&version=3.24.1125.181
                    
Install EasilyNET.RabbitBus.AspNetCore as a Cake Tool
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 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.  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. 
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
4.25.506.150 35 5/6/2025
4.25.429.162 113 4/29/2025
4.25.429.103 139 4/29/2025
4.25.411.142 107 4/11/2025
4.25.409.92 127 4/9/2025
4.25.403.133 126 4/3/2025
4.25.319.113 137 3/19/2025
4.25.312.103 141 3/12/2025
4.25.227.135 75 2/27/2025
4.25.221.115 103 2/21/2025
4.25.212.95 225 2/12/2025
4.25.211.140 80 2/11/2025
4.25.124.223 61 1/24/2025
4.25.116.110 91 1/16/2025
4.25.115.121 59 1/15/2025
4.25.114.172 91 1/14/2025
4.25.109.111 89 1/9/2025
4.25.108.182 88 1/8/2025
4.25.108.160 83 1/8/2025
4.25.1.1 117 1/1/2025
3.24.1224.141 99 12/24/2024
3.24.1216.116 112 12/16/2024
3.24.1206.100 73 12/6/2024
3.24.1205.171 78 12/5/2024
3.24.1202.150 74 12/2/2024
3.24.1126.231 77 11/26/2024
3.24.1126.172 72 11/26/2024
3.24.1126.114 72 11/26/2024
3.24.1126.104 71 11/26/2024
3.24.1125.181 64 11/25/2024
3.24.1125.104 72 11/25/2024
3.24.1121.183 68 11/21/2024
3.24.1120.183 67 11/20/2024
3.24.1119.31 69 11/18/2024
3.24.1115.143 58 11/15/2024
3.24.1113.100 73 11/13/2024
3.24.1112.125 561 11/12/2024
3.24.1107.140 66 11/7/2024
3.24.1107.54 66 11/7/2024
3.24.1107.34 68 11/7/2024
3.24.1105.111 71 11/5/2024
3.24.1103.31 76 11/2/2024
3.24.1103 73 11/2/2024
3.24.1031.135 66 10/31/2024
3.24.1031.112 67 10/31/2024
3.24.1031.104 70 10/31/2024
3.24.1029.142 71 10/29/2024
3.24.1025.30 166 10/24/2024
3.24.1022.142 61 10/22/2024
3.24.1018.204 124 10/18/2024
3.24.1018.175 116 10/18/2024
3.24.1018.166 115 10/18/2024
3.24.1018.93 119 10/18/2024
3.24.1017.42 69 10/16/2024
3.24.1016.161 71 10/16/2024
3.24.1015.231 70 10/15/2024
3.24.1015.14 72 10/14/2024
3.24.1012.114 67 10/12/2024
3.24.1009.115 73 10/9/2024
3.24.1008.160 70 10/8/2024
3.24.1008.133 65 10/8/2024
3.24.1007.185 69 10/7/2024
3.24.1003.33 76 10/2/2024
3.24.1002.162 75 10/2/2024
3.24.929.143 72 9/29/2024
3.24.929.141 71 9/29/2024
3.24.929.131 70 9/29/2024
3.24.929.122 73 9/29/2024
3.24.926.184 73 9/26/2024
3.24.926.182 73 9/26/2024
3.24.926.175 77 9/26/2024
3.24.924.160 74 9/24/2024
3.24.924.133 81 9/24/2024
3.24.924.124 72 9/24/2024
3.24.924.10 75 9/23/2024
3.24.924.1 66 9/23/2024
3.24.923.234 70 9/23/2024
3.24.923.232 73 9/23/2024
3.24.923.155 70 9/23/2024
3.24.919.92 84 9/19/2024
3.24.914.125 77 9/14/2024
3.24.914.115 73 9/14/2024
3.24.914.111 74 9/14/2024
3.24.911.95 73 9/11/2024
3.24.908.215 67 9/8/2024
3.24.904.200 73 9/4/2024
3.24.828.163 81 8/28/2024
3.24.820.173 81 8/20/2024
3.24.814.92 90 8/14/2024
3.24.812.115 84 8/12/2024
3.24.802.100 63 8/2/2024
3.24.801.162 68 8/1/2024
3.24.801.160 71 8/1/2024
3.24.801.155 71 8/1/2024
3.24.730.164 60 7/30/2024
3.24.730.91 56 7/30/2024
3.24.724.91 66 7/24/2024
3.24.718.105 88 7/18/2024
3.24.716.95 77 7/16/2024
3.24.712.94 77 7/12/2024
3.24.710.14 72 7/9/2024
3.24.709.105 78 7/9/2024
3.24.704.94 74 7/4/2024
3.24.701.90 73 7/1/2024
3.24.628.114 80 6/28/2024
3.24.627.145 74 6/27/2024
3.24.620.160 81 6/20/2024
3.24.613.115 76 6/13/2024
3.24.612.95 80 6/12/2024
3.24.528.90 75 5/28/2024
3.24.522.84 91 5/22/2024
3.24.512.213 73 5/12/2024
3.24.508.112 90 5/8/2024
2.2024.428.71 85 4/28/2024
2.2024.427.1128 85 4/27/2024
2.2.72 95 4/14/2024
2.2.71 75 4/12/2024
2.2.8 80 4/26/2024
2.2.6 75 4/10/2024
2.2.5 96 3/26/2024
2.2.4 93 3/25/2024
2.2.3 84 3/24/2024
2.2.2 89 3/21/2024
2.2.1 92 3/20/2024
2.2.0 97 3/13/2024
2.1.9 92 2/21/2024
2.1.8 93 2/18/2024
2.1.7 93 2/16/2024
2.1.6 108 2/14/2024
2.1.5 85 2/14/2024
2.1.4 108 2/9/2024
2.1.3 89 2/8/2024
2.1.2 117 2/5/2024
2.1.1.2 166 12/26/2023
2.1.1.1 101 12/26/2023
2.1.1 103 12/25/2023
2.1.0 120 12/17/2023
2.0.11 144 12/6/2023
2.0.1 140 11/15/2023
2.0.0 98 11/14/2023
1.9.1 113 11/1/2023
1.9.0 107 10/19/2023
1.9.0-preview2 225 10/12/2023
1.9.0-preview1 83 10/12/2023
1.8.9 133 10/11/2023
1.8.8 126 10/11/2023
1.8.7-rc2 89 9/21/2023
1.8.7-rc1 86 9/12/2023
1.8.6 127 8/31/2023
1.8.5 551 8/25/2023
1.8.4 116 8/24/2023
1.8.3 114 8/23/2023
1.8.2 156 8/22/2023
1.8.1 117 8/18/2023
1.8.0 120 8/15/2023
1.7.9 142 8/11/2023
1.7.8 116 8/11/2023
1.7.7 128 8/10/2023
1.7.6 123 8/9/2023
1.7.5 146 8/9/2023
1.7.4 164 8/3/2023
1.7.3 131 8/1/2023
1.7.2 129 7/31/2023
1.7.1 123 7/27/2023
1.7.0 129 7/25/2023
1.6.9 130 7/25/2023
1.6.8 119 7/24/2023
1.6.7 135 7/20/2023
1.6.6 130 7/19/2023
1.6.5 101 7/19/2023
1.6.4 121 7/17/2023
1.6.3 117 7/17/2023
1.6.2 137 7/12/2023
1.6.1 135 6/30/2023
1.6.0 118 6/30/2023