11using System . Linq ;
22using Microsoft . Extensions . Configuration ;
33using Microsoft . Extensions . DependencyInjection ;
4+ using Microsoft . Extensions . DependencyInjection . Extensions ;
45using RabbitMQ . Client . Core . DependencyInjection . BatchMessageHandlers ;
56using RabbitMQ . Client . Core . DependencyInjection . Configuration ;
67using RabbitMQ . Client . Core . DependencyInjection . Exceptions ;
78using RabbitMQ . Client . Core . DependencyInjection . InternalExtensions ;
89using RabbitMQ . Client . Core . DependencyInjection . Models ;
10+ using RabbitMQ . Client . Core . DependencyInjection . Services ;
911
1012namespace RabbitMQ . Client . Core . DependencyInjection
1113{
@@ -25,6 +27,7 @@ public static IServiceCollection AddBatchMessageHandler<TBatchMessageHandler>(th
2527 where TBatchMessageHandler : BaseBatchMessageHandler
2628 {
2729 CheckIfBatchMessageHandlerAlreadyConfigured < TBatchMessageHandler > ( services ) ;
30+ services . TryAddSingleton < IRabbitMqConnectionFactory , RabbitMqConnectionFactory > ( ) ;
2831 var configurationInstance = RabbitMqClientOptionsDependencyInjectionExtensions . GetRabbitMqClientOptionsInstance ( configuration ) ;
2932 services . ConfigureBatchConsumerConnectionOptions < TBatchMessageHandler > ( configurationInstance ) ;
3033 services . AddHostedService < TBatchMessageHandler > ( ) ;
@@ -42,6 +45,7 @@ public static IServiceCollection AddBatchMessageHandler<TBatchMessageHandler>(th
4245 where TBatchMessageHandler : BaseBatchMessageHandler
4346 {
4447 CheckIfBatchMessageHandlerAlreadyConfigured < TBatchMessageHandler > ( services ) ;
48+ services . TryAddSingleton < IRabbitMqConnectionFactory , RabbitMqConnectionFactory > ( ) ;
4549 services . ConfigureBatchConsumerConnectionOptions < TBatchMessageHandler > ( configuration ) ;
4650 services . AddHostedService < TBatchMessageHandler > ( ) ;
4751 return services ;
0 commit comments