@@ -39,22 +39,8 @@ public static IServiceCollection AddRabbitMqClient(this IServiceCollection servi
3939 public static IServiceCollection AddRabbitMqClient ( this IServiceCollection services , RabbitMqClientOptions configuration )
4040 {
4141 services . AddRabbitMqClientInfrastructure ( ) ;
42+ services . ConfigureRabbitMqClientOptions ( configuration ) ;
4243 services . AddSingleton < IQueueService , QueueService > ( ) ;
43- services . Configure < RabbitMqClientOptions > ( opt =>
44- {
45- opt . HostName = configuration . HostName ;
46- opt . HostNames = configuration . HostNames ;
47- opt . TcpEndpoints = configuration . TcpEndpoints ;
48- opt . Port = configuration . Port ;
49- opt . UserName = configuration . UserName ;
50- opt . Password = configuration . Password ;
51- opt . VirtualHost = configuration . VirtualHost ;
52- opt . AutomaticRecoveryEnabled = configuration . AutomaticRecoveryEnabled ;
53- opt . TopologyRecoveryEnabled = configuration . TopologyRecoveryEnabled ;
54- opt . RequestedConnectionTimeout = configuration . RequestedConnectionTimeout ;
55- opt . RequestedHeartbeat = configuration . RequestedHeartbeat ;
56- opt . ClientProvidedName = configuration . ClientProvidedName ;
57- } ) ;
5844 return services ;
5945 }
6046
@@ -70,8 +56,8 @@ public static IServiceCollection AddRabbitMqClient(this IServiceCollection servi
7056 public static IServiceCollection AddRabbitMqClientTransient ( this IServiceCollection services , IConfiguration configuration )
7157 {
7258 services . AddRabbitMqClientInfrastructure ( ) ;
73- services . AddTransient < IQueueService , QueueService > ( ) ;
7459 services . Configure < RabbitMqClientOptions > ( configuration ) ;
60+ services . AddTransient < IQueueService , QueueService > ( ) ;
7561 return services ;
7662 }
7763
@@ -87,7 +73,22 @@ public static IServiceCollection AddRabbitMqClientTransient(this IServiceCollect
8773 public static IServiceCollection AddRabbitMqClientTransient ( this IServiceCollection services , RabbitMqClientOptions configuration )
8874 {
8975 services . AddRabbitMqClientInfrastructure ( ) ;
76+ services . ConfigureRabbitMqClientOptions ( configuration ) ;
9077 services . AddTransient < IQueueService , QueueService > ( ) ;
78+ return services ;
79+ }
80+
81+ static IServiceCollection AddRabbitMqClientInfrastructure ( this IServiceCollection services )
82+ {
83+ services . AddOptions ( ) ;
84+ services . AddLogging ( options => options . AddConsole ( ) ) ;
85+ services . AddSingleton < IMessageHandlerContainerBuilder , MessageHandlerContainerBuilder > ( ) ;
86+ services . AddSingleton < IMessageHandlingService , MessageHandlingService > ( ) ;
87+ return services ;
88+ }
89+
90+ static IServiceCollection ConfigureRabbitMqClientOptions ( this IServiceCollection services , RabbitMqClientOptions configuration )
91+ {
9192 services . Configure < RabbitMqClientOptions > ( opt =>
9293 {
9394 opt . HostName = configuration . HostName ;
@@ -105,14 +106,5 @@ public static IServiceCollection AddRabbitMqClientTransient(this IServiceCollect
105106 } ) ;
106107 return services ;
107108 }
108-
109- static IServiceCollection AddRabbitMqClientInfrastructure ( this IServiceCollection services )
110- {
111- services . AddOptions ( ) ;
112- services . AddLogging ( options => options . AddConsole ( ) ) ;
113- services . AddSingleton < IMessageHandlerContainerBuilder , MessageHandlerContainerBuilder > ( ) ;
114- services . AddSingleton < IMessageHandlingService , MessageHandlingService > ( ) ;
115- return services ;
116- }
117109 }
118110}
0 commit comments