Merge pull request '🍒 fix(EventBus): 默认不使用RabbitMQ中间件处理事件源,防止没环境抛异常' (#423) from jasondom/Admin.NET.Pro:v2-fix into v2
Reviewed-on: https://code.adminnet.top/Admin.NET/Admin.NET.Pro/pulls/423
This commit is contained in:
commit
f9f90d8b1a
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
"EventBus": {
|
"EventBus": {
|
||||||
// 事件源存储器类型,默认内存存储(Redis则需要配合缓存相关配置)
|
// 事件源存储器类型,默认内存存储(Redis则需要配合缓存相关配置)
|
||||||
"EventSourceType": "RabbitMQ", // Memory、Redis、RabbitMQ、Kafka
|
"EventSourceType": "Memory", // Memory、Redis、RabbitMQ、Kafka
|
||||||
|
|
||||||
"Kafka": {
|
"Kafka": {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,10 +14,13 @@ public static class RabbitMQExtention
|
|||||||
public static IServiceCollection AddRabbitMQ<THandler>(this IServiceCollection services)
|
public static IServiceCollection AddRabbitMQ<THandler>(this IServiceCollection services)
|
||||||
where THandler : class, IMessageHandler
|
where THandler : class, IMessageHandler
|
||||||
{
|
{
|
||||||
services.AddSingleton<IMessageHandler, THandler>();
|
if (App.GetConfig<string>("EventBus:EventSourceType", true) == "RabbitMQ")
|
||||||
services.AddSingleton<RabbitMqConnection>();
|
{
|
||||||
services.AddSingleton<RabbitMqProducer>();
|
services.AddSingleton<IMessageHandler, THandler>();
|
||||||
services.AddHostedService<RabbitMqConsumer>();
|
services.AddSingleton<RabbitMqConnection>();
|
||||||
|
services.AddSingleton<RabbitMqProducer>();
|
||||||
|
services.AddHostedService<RabbitMqConsumer>();
|
||||||
|
}
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user