fix: 租户端启动补齐字典与消息依赖

This commit is contained in:
root
2026-01-30 02:42:22 +00:00
parent f1963ae1a5
commit 8e315e4f17
5 changed files with 82 additions and 3 deletions

View File

@@ -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();