v3.4.6
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using JNPF;
|
||||
using JNPF.Common.Core;
|
||||
using JNPF.Common.Options;
|
||||
using JNPF.EventHandler;
|
||||
using OnceMi.AspNetCore.OSS;
|
||||
@@ -17,40 +18,53 @@ public static class ConfigureEventBusExtensions
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection ConfigureEventBus(this IServiceCollection services)
|
||||
{
|
||||
// 注册EventBus服务
|
||||
services.AddEventBus(options =>
|
||||
{
|
||||
//// 创建连接工厂
|
||||
//var factory = new RabbitMQ.Client.ConnectionFactory
|
||||
//{
|
||||
// // 设置主机名
|
||||
// HostName = "192.168.0.232",
|
||||
// 注册EventBus服务
|
||||
// 注册EventBus服务
|
||||
services.AddEventBus(options =>
|
||||
{
|
||||
var config = App.GetOptions<EventBusOptions>();
|
||||
|
||||
// // 用户名
|
||||
// UserName = "jnpf",
|
||||
if (config.EventBusType != EventBusType.Memory)
|
||||
{
|
||||
switch (config.EventBusType)
|
||||
{
|
||||
case EventBusType.RabbitMQ:
|
||||
// 创建连接工厂
|
||||
var factory = new RabbitMQ.Client.ConnectionFactory
|
||||
{
|
||||
// 设置主机名
|
||||
HostName = config.HostName,
|
||||
|
||||
// // 密码
|
||||
// Password = "jnpf@2019",
|
||||
//};
|
||||
// 用户名
|
||||
UserName = config.UserName,
|
||||
|
||||
//// 创建默认内存通道事件源对象,可自定义队列路由key,比如这里是 eventbus
|
||||
//var rbmqEventSourceStorer = new RabbitMQEventSourceStorer(factory, "eventbus", 3000);
|
||||
// 密码
|
||||
Password = config.Password,
|
||||
};
|
||||
|
||||
//// 替换默认事件总线存储器
|
||||
//options.ReplaceStorer(serviceProvider =>
|
||||
//{
|
||||
// return rbmqEventSourceStorer;
|
||||
//});
|
||||
// 创建默认内存通道事件源对象,可自定义队列路由key,比如这里是 eventbus
|
||||
var rbmqEventSourceStorer = new RabbitMQEventSourceStorer(factory, "eventbus", 3000);
|
||||
|
||||
options.UseUtcTimestamp = false;
|
||||
// 替换默认事件总线存储器
|
||||
options.ReplaceStorer(serviceProvider =>
|
||||
{
|
||||
return rbmqEventSourceStorer;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 不启用事件日志
|
||||
options.LogEnabled = false;
|
||||
options.UseUtcTimestamp = false;
|
||||
|
||||
// 事件执行器(失败重试)
|
||||
options.AddExecutor<RetryEventHandlerExecutor>();
|
||||
});
|
||||
// 不启用事件日志
|
||||
options.LogEnabled = false;
|
||||
|
||||
return services;
|
||||
// 事件执行器(失败重试)
|
||||
options.AddExecutor<RetryEventHandlerExecutor>();
|
||||
});
|
||||
|
||||
services.AddConfigurableOptions<EventBusOptions>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user