简化startup

This commit is contained in:
2023-03-28 15:29:09 +08:00
parent 847a858d4c
commit d636034f06
10 changed files with 221 additions and 173 deletions

View File

@@ -0,0 +1,56 @@
using JNPF;
using JNPF.Common.Options;
using JNPF.EventHandler;
using OnceMi.AspNetCore.OSS;
namespace Microsoft.Extensions.DependencyInjection;
/// <summary>
/// OSS服务配置拓展.
/// </summary>
public static class ConfigureEventBusExtensions
{
/// <summary>
/// OSS服务配置.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection ConfigureEventBus(this IServiceCollection services)
{
// 注册EventBus服务
services.AddEventBus(options =>
{
//// 创建连接工厂
//var factory = new RabbitMQ.Client.ConnectionFactory
//{
// // 设置主机名
// HostName = "192.168.0.232",
// // 用户名
// UserName = "jnpf",
// // 密码
// Password = "jnpf@2019",
//};
//// 创建默认内存通道事件源对象可自定义队列路由key比如这里是 eventbus
//var rbmqEventSourceStorer = new RabbitMQEventSourceStorer(factory, "eventbus", 3000);
//// 替换默认事件总线存储器
//options.ReplaceStorer(serviceProvider =>
//{
// return rbmqEventSourceStorer;
//});
options.UseUtcTimestamp = false;
// 不启用事件日志
options.LogEnabled = false;
// 事件执行器(失败重试)
options.AddExecutor<RetryEventHandlerExecutor>();
});
return services;
}
}