EasilyNET.RabbitBus.AspNetCore 3.24.1206.100

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.1206.100                
NuGet\Install-Package EasilyNET.RabbitBus.AspNetCore -Version 3.24.1206.100                
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.1206.100" />                
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.1206.100                
#r "nuget: EasilyNET.RabbitBus.AspNetCore, 3.24.1206.100"                
#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.1206.100

// Install EasilyNET.RabbitBus.AspNetCore as a Cake Tool
#tool nuget:?package=EasilyNET.RabbitBus.AspNetCore&version=3.24.1206.100                
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. 
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
3.24.1216.116 75 3 days ago
3.24.1206.100 49 13 days ago
3.24.1205.171 53 14 days ago
3.24.1202.150 50 17 days ago
3.24.1126.231 55 22 days ago
3.24.1126.172 54 23 days ago
3.24.1126.114 53 23 days ago
3.24.1126.104 49 23 days ago
3.24.1125.181 44 24 days ago
3.24.1125.104 53 24 days ago
3.24.1121.183 49 a month ago
3.24.1120.183 49 a month ago
3.24.1119.31 50 a month ago
3.24.1115.143 39 a month ago
3.24.1113.100 52 a month ago
3.24.1112.125 128 a month ago
3.24.1107.140 47 a month ago
3.24.1107.54 49 a month ago
3.24.1107.34 51 a month ago
3.24.1105.111 53 a month ago
3.24.1103.31 57 2 months ago
3.24.1103 53 2 months ago
3.24.1031.135 46 2 months ago
3.24.1031.112 48 2 months ago
3.24.1031.104 48 2 months ago
3.24.1029.142 52 2 months ago
3.24.1025.30 148 2 months ago
3.24.1022.142 43 2 months ago
3.24.1018.204 107 2 months ago
3.24.1018.175 104 2 months ago
3.24.1018.166 103 2 months ago
3.24.1018.93 104 2 months ago
3.24.1017.42 54 2 months ago
3.24.1016.161 56 2 months ago
3.24.1015.231 56 2 months ago
3.24.1015.14 58 2 months ago
3.24.1012.114 52 2 months ago
3.24.1009.115 57 2 months ago
3.24.1008.160 57 2 months ago
3.24.1008.133 51 2 months ago
3.24.1007.185 54 2 months ago
3.24.1003.33 60 3 months ago
3.24.1002.162 59 3 months ago
3.24.929.143 55 3 months ago
3.24.929.141 53 3 months ago
3.24.929.131 53 3 months ago
3.24.929.122 57 3 months ago
3.24.926.184 59 3 months ago
3.24.926.182 56 3 months ago
3.24.926.175 59 3 months ago
3.24.924.160 57 3 months ago
3.24.924.133 68 3 months ago
3.24.924.124 57 3 months ago
3.24.924.10 59 3 months ago
3.24.924.1 49 3 months ago
3.24.923.234 53 3 months ago
3.24.923.232 55 3 months ago
3.24.923.155 54 3 months ago
3.24.919.92 67 3 months ago
3.24.914.125 63 3 months ago
3.24.914.115 63 3 months ago
3.24.914.111 63 3 months ago
3.24.911.95 62 3 months ago
3.24.908.215 54 3 months ago
3.24.904.200 64 3 months ago
3.24.828.163 68 4 months ago
3.24.820.173 72 4 months ago
3.24.814.92 80 4 months ago
3.24.812.115 72 4 months ago
3.24.802.100 49 5 months ago
3.24.801.162 56 5 months ago
3.24.801.160 58 5 months ago
3.24.801.155 58 5 months ago
3.24.730.164 47 5 months ago
3.24.730.91 43 5 months ago
3.24.724.91 53 5 months ago
3.24.718.105 76 5 months ago
3.24.716.95 65 5 months ago
3.24.712.94 58 5 months ago
3.24.710.14 59 5 months ago
3.24.709.105 66 5 months ago
3.24.704.94 61 5 months ago
3.24.701.90 59 6 months ago
3.24.628.114 68 6 months ago
3.24.627.145 61 6 months ago
3.24.620.160 67 6 months ago
3.24.613.115 63 6 months ago
3.24.612.95 68 6 months ago
3.24.528.90 65 7 months ago
3.24.522.84 81 7 months ago
3.24.512.213 62 7 months ago
3.24.508.112 81 7 months ago
2.2024.428.71 74 8 months ago
2.2024.427.1128 76 8 months ago
2.2.72 84 8 months ago
2.2.71 65 8 months ago
2.2.8 69 8 months ago
2.2.6 65 8 months ago
2.2.5 85 9 months ago
2.2.4 82 9 months ago
2.2.3 73 9 months ago
2.2.2 78 9 months ago
2.2.1 80 9 months ago
2.2.0 86 9 months ago
2.1.9 78 10 months ago
2.1.8 79 10 months ago
2.1.7 80 2/16/2024
2.1.6 93 2/14/2024
2.1.5 70 2/14/2024
2.1.4 99 2/9/2024
2.1.3 77 2/8/2024
2.1.2 107 2/5/2024
2.1.1.2 156 12/26/2023
2.1.1.1 92 12/26/2023
2.1.1 90 12/25/2023
2.1.0 108 12/17/2023
2.0.11 141 12/6/2023
2.0.1 136 11/15/2023
2.0.0 92 11/14/2023
1.9.1 109 11/1/2023
1.9.0 102 10/19/2023
1.9.0-preview2 205 10/12/2023
1.9.0-preview1 80 10/12/2023
1.8.9 128 10/11/2023
1.8.8 122 10/11/2023
1.8.7-rc2 86 9/21/2023
1.8.7-rc1 82 9/12/2023
1.8.6 122 8/31/2023
1.8.5 533 8/25/2023
1.8.4 112 8/24/2023
1.8.3 108 8/23/2023
1.8.2 152 8/22/2023
1.8.1 112 8/18/2023
1.8.0 113 8/15/2023
1.7.9 137 8/11/2023
1.7.8 110 8/11/2023
1.7.7 123 8/10/2023
1.7.6 119 8/9/2023
1.7.5 141 8/9/2023
1.7.4 159 8/3/2023
1.7.3 126 8/1/2023
1.7.2 124 7/31/2023
1.7.1 117 7/27/2023
1.7.0 124 7/25/2023
1.6.9 125 7/25/2023
1.6.8 115 7/24/2023
1.6.7 129 7/20/2023
1.6.6 123 7/19/2023
1.6.5 93 7/19/2023
1.6.4 115 7/17/2023
1.6.3 111 7/17/2023
1.6.2 128 7/12/2023
1.6.1 129 6/30/2023
1.6.0 108 6/30/2023