EasilyNET.RabbitBus.AspNetCore 2.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasilyNET.RabbitBus.AspNetCore --version 2.1.1                
NuGet\Install-Package EasilyNET.RabbitBus.AspNetCore -Version 2.1.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="EasilyNET.RabbitBus.AspNetCore" Version="2.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasilyNET.RabbitBus.AspNetCore --version 2.1.1                
#r "nuget: EasilyNET.RabbitBus.AspNetCore, 2.1.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.
// Install EasilyNET.RabbitBus.AspNetCore as a Cake Addin
#addin nuget:?package=EasilyNET.RabbitBus.AspNetCore&version=2.1.1

// Install EasilyNET.RabbitBus.AspNetCore as a Cake Tool
#tool nuget:?package=EasilyNET.RabbitBus.AspNetCore&version=2.1.1                
EasilyNET.RabbitBus.AspNetCore
如何使用
  • 首先使用 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";
    ...
});

// 注册服务
builder.Services.AddTransient<TestEventHandler>();
  • Step2.接下来配置事件和事件处理器
/// <summary>
/// 测试消息类型
/// </summary>
[Rabbit("hoyo.test", EExchange.Routing, "test", "orderqueue2")]
public class TestEvent : IntegrationEvent
{
    /// <summary>
    /// 消息
    /// </summary>
    public string Message { get; set; } = default!;
}

/// <summary>
/// 消息处理Handler
/// </summary>
public class TestEventHandler : IIntegrationEventHandler<TestEvent>
{
    private readonly ILogger<TestEventHandler> _logger;
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="logger"></param>
    public TestEventHandler(ILogger<TestEventHandler> logger)
    {
        _logger = logger;
    }
    /// <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 IIntegrationEventBus _ibus;
// 控制器构造函数伪代码
construct(IIntegrationEventBus ibus){
   _ibus = ibus;
}
/// <summary>
/// 创建一个延时消息,同时发送一个普通消息做对比
/// </summary>
[HttpPost("TTLTest")]
public void 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}" };
    // 延时队列需要服务端安装延时队列插件.
    _ibus.Publish(ttlobj, (uint)ttl);
    _ibus.Publish(ttlobj);
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
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.924.10 0 9/23/2024
3.24.924.1 0 9/23/2024
3.24.923.234 0 9/23/2024
3.24.923.232 0 9/23/2024
3.24.923.155 19 9/23/2024
3.24.919.92 47 9/19/2024
3.24.914.125 35 9/14/2024
3.24.914.115 35 9/14/2024
3.24.914.111 37 9/14/2024
3.24.911.95 40 9/11/2024
3.24.908.215 33 9/8/2024
3.24.904.200 40 9/4/2024
3.24.828.163 54 8/28/2024
3.24.820.173 54 8/20/2024
3.24.814.92 64 8/14/2024
3.24.812.115 56 8/12/2024
3.24.802.100 32 8/2/2024
3.24.801.162 41 8/1/2024
3.24.801.160 38 8/1/2024
3.24.801.155 42 8/1/2024
3.24.730.164 31 7/30/2024
3.24.730.91 31 7/30/2024
3.24.724.91 37 7/24/2024
3.24.718.105 61 7/18/2024
3.24.716.95 48 7/16/2024
3.24.712.94 41 7/12/2024
3.24.710.14 44 7/9/2024
3.24.709.105 45 7/9/2024
3.24.704.94 50 7/4/2024
3.24.701.90 47 7/1/2024
3.24.628.114 54 6/28/2024
3.24.627.145 44 6/27/2024
3.24.620.160 54 6/20/2024
3.24.613.115 51 6/13/2024
3.24.612.95 57 6/12/2024
3.24.528.90 52 5/28/2024
3.24.522.84 63 5/22/2024
3.24.512.213 49 5/12/2024
3.24.508.112 65 5/8/2024
2.2024.428.71 57 4/28/2024
2.2024.427.1128 63 4/27/2024
2.2.72 73 4/14/2024
2.2.71 53 4/12/2024
2.2.8 51 4/26/2024
2.2.6 54 4/10/2024
2.2.5 72 3/26/2024
2.2.4 72 3/25/2024
2.2.3 59 3/24/2024
2.2.2 66 3/21/2024
2.2.1 69 3/20/2024
2.2.0 75 3/13/2024
2.1.9 67 2/21/2024
2.1.8 67 2/18/2024
2.1.7 71 2/16/2024
2.1.6 77 2/14/2024
2.1.5 60 2/14/2024
2.1.4 85 2/9/2024
2.1.3 61 2/8/2024
2.1.2 89 2/5/2024
2.1.1.2 143 12/26/2023
2.1.1.1 77 12/26/2023
2.1.1 78 12/25/2023
2.1.0 95 12/17/2023
2.0.11 131 12/6/2023
2.0.1 123 11/15/2023
2.0.0 74 11/14/2023
1.9.1 99 11/1/2023
1.9.0 86 10/19/2023
1.9.0-preview2 176 10/12/2023
1.9.0-preview1 69 10/12/2023
1.8.9 118 10/11/2023
1.8.8 110 10/11/2023
1.8.7-rc2 76 9/21/2023
1.8.7-rc1 73 9/12/2023
1.8.6 104 8/31/2023
1.8.5 457 8/25/2023
1.8.4 102 8/24/2023
1.8.3 97 8/23/2023
1.8.2 143 8/22/2023
1.8.1 103 8/18/2023
1.8.0 101 8/15/2023
1.7.9 127 8/11/2023
1.7.8 92 8/11/2023
1.7.7 111 8/10/2023
1.7.6 109 8/9/2023
1.7.5 132 8/9/2023
1.7.4 148 8/3/2023
1.7.3 114 8/1/2023
1.7.2 115 7/31/2023
1.7.1 105 7/27/2023
1.7.0 114 7/25/2023
1.6.9 116 7/25/2023
1.6.8 104 7/24/2023
1.6.7 120 7/20/2023
1.6.6 111 7/19/2023
1.6.5 81 7/19/2023
1.6.4 104 7/17/2023
1.6.3 99 7/17/2023
1.6.2 118 7/12/2023
1.6.1 117 6/30/2023
1.6.0 99 6/30/2023