fix: 租户端启动补齐字典与消息依赖
This commit is contained in:
@@ -17,8 +17,17 @@ public static class MessagingServiceCollectionExtensions
|
||||
/// </summary>
|
||||
public static IServiceCollection AddMessagingModule(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var rabbitMqSection = configuration.GetSection("RabbitMQ");
|
||||
if (!rabbitMqSection.Exists())
|
||||
{
|
||||
services.AddSingleton<IMessagePublisher, NoOpMessagePublisher>();
|
||||
services.AddSingleton<IMessageSubscriber, NoOpMessageSubscriber>();
|
||||
return services;
|
||||
}
|
||||
|
||||
// 1. (空行后) 存在 RabbitMQ 配置时才启用真实 MQ 能力(启动时验证配置完整性)
|
||||
services.AddOptions<RabbitMqOptions>()
|
||||
.Bind(configuration.GetSection("RabbitMQ"))
|
||||
.Bind(rabbitMqSection)
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user