Jaina 4.0.0
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 Jaina --version 4.0.0
NuGet\Install-Package Jaina -Version 4.0.0
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="Jaina" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jaina --version 4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jaina, 4.0.0"
#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 Jaina as a Cake Addin #addin nuget:?package=Jaina&version=4.0.0 // Install Jaina as a Cake Tool #tool nuget:?package=Jaina&version=4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Jaina
.NET 事件总线,简化项目、类库、线程、服务等之间的通信,代码更少,质量更好。
特性
- 简化组件之间通信
- 支持事件监视器
- 支持动作执行器
- 支持自定义消息存储组件
- 支持自定义策略执行
- 支持单消费、多消费消息
- 支持消息幂等性处理
- 高内聚,低耦合,使代码更简单
- 非常快速,每秒可处理
30000 +
消息 - 很小,仅
10KB
- 无第三方依赖
- 可在
Windows/Linux/MacOS
守护进程部署 - 支持分布式、集群
- 高质量代码和良好单元测试
安装
Install-Package Jaina
dotnet add package Jaina
快速入门
我们在主页上有不少例子,这是让您入门的第一个:
- 定义事件订阅者
ToDoEventSubscriber
:
// 实现 IEventSubscriber 接口
public class ToDoEventSubscriber : IEventSubscriber
{
private readonly ILogger<ToDoEventSubscriber> _logger;
public ToDoEventSubscriber(ILogger<ToDoEventSubscriber> logger)
{
_logger = logger;
}
[EventSubscribe("ToDo:Create")] // 支持多个
[EventSubscribe(YourEnum.Message)] // 支持枚举
public async Task CreateToDo(EventHandlerExecutingContext context)
{
var todo = context.Source;
_logger.LogInformation("创建一个 ToDo:{Name}", todo.Payload);
await Task.CompletedTask;
}
// 支持枚举类型
[EventSubscribe(YourEnum.Some)]
public async Task EnumHandler(EventHandlerExecutingContext context)
{
var eventEnum = context.Source.EventId.ParseToEnum(); // 将事件 Id 转换成枚举对象
await Task.CompletedTask;
}
// 支持正则表达式匹配
[EventSubscribe("(^1[3456789][0-9]{9}$)|((^[0-9]{3,4}\\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\\([0-9]{3,4}\\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$))", FuzzyMatch = true)]
public async Task RegexHandler(EventHandlerExecutingContext context)
{
var eventId = context.Source.EventId;
await Task.CompletedTask;
}
// 支持多种异常重试配置
[EventSubscribe("test:error", NumRetries = 3)]
[EventSubscribe("test:error", NumRetries = 3, RetryTimeout = 1000)] // 重试间隔时间
[EventSubscribe("test:error", NumRetries = 3, ExceptionTypes = new[] { typeof(ArgumentException) })] // 特定类型异常才重试
public async Task ExceptionHandler(EventHandlerExecutingContext context)
{
var eventId = context.Source.EventId;
await Task.CompletedTask;
}
}
- 创建控制器
ToDoController
,依赖注入IEventPublisher
服务:
public class ToDoController : ControllerBase
{
// 依赖注入事件发布者 IEventPublisher
private readonly IEventPublisher _eventPublisher;
public ToDoController(IEventPublisher eventPublisher)
{
_eventPublisher = eventPublisher;
}
// 发布 ToDo:Create 消息
public async Task CreateDoTo(string name)
{
await _eventPublisher.PublishAsync(new ChannelEventSource("ToDo:Create", name));
// 简化版本
await _eventPublisher.PublishAsync("ToDo:Create", name);
}
}
- 在
Startup.cs
注册EventBus
服务:
// 注册 EventBus 服务
services.AddEventBus(builder =>
{
// 注册 ToDo 事件订阅者
builder.AddSubscriber<ToDoEventSubscriber>();
// 通过类型注册
builder.AddSubscriber(typeof(ToDoEventSubscriber));
// 批量注册事件订阅者
builder.AddSubscribers(ass1, ass2, ....);
});
- 运行项目:
info: Jaina.Samples.ToDoEventSubscriber[0]
创建一个 ToDo:Jaina
文档
您可以在主页找到 Jaina 文档。
贡献
该存储库的主要目的是继续发展 Jaina 核心,使其更快、更易于使用。Jaina 的开发在 Gitee 上公开进行,我们感谢社区贡献错误修复和改进。
许可证
Jaina 采用 MIT 开源许可证。
MIT License
Copyright (c) 2020-2022 百小僧, Baiqian Co.,Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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 was computed. 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.
-
net5.0
- Microsoft.Extensions.Hosting.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
- Newtonsoft.Json (>= 13.0.1)
-
net6.0
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.1)
-
net7.0
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.1)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Jaina:
Package | Downloads |
---|---|
Mk.FrameworkCore
Private development class library. |
|
GM-W-04.Service
Package Description |
|
DqCloud.Service
Package Description |
|
HZPOST.Infrastructure
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
4.3.0 | 4,046 | 3/18/2024 | |
4.2.0 | 206 | 2/3/2024 | |
4.1.2 | 7,602 | 4/13/2023 | |
4.1.1 | 2,798 | 3/6/2023 | |
4.1.0 | 244 | 2/22/2023 | |
4.0.0 | 2,448 | 11/23/2022 | |
3.2.0 | 338 | 10/31/2022 | |
3.1.3 | 1,854 | 8/30/2022 | |
3.1.2 | 169 | 8/30/2022 | |
3.1.1 | 342 | 8/24/2022 | |
3.1.0 | 181 | 8/24/2022 | |
3.0.1 | 840 | 8/17/2022 | |
3.0.0 | 5,761 | 8/1/2022 | |
2.0.1 | 8,347 | 6/9/2022 | |
2.0.0 | 2,406 | 11/11/2021 | |
1.0.9 | 1,256 | 11/1/2021 | |
1.0.8 | 421 | 11/1/2021 | |
1.0.7 | 457 | 10/29/2021 | |
1.0.6 | 449 | 10/29/2021 | |
1.0.5 | 553 | 10/27/2021 |