|
31 | 31 | using System; |
32 | 32 | using System.Data.Common; |
33 | 33 | using System.Reflection; |
34 | | - using global::Ordering.API.Application.IntegrationEvents.EventHandling; |
35 | 34 |
|
36 | 35 | public class Startup |
37 | 36 | { |
@@ -125,13 +124,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services) |
125 | 124 | return new DefaultRabbitMQPersistentConnection(factory, logger); |
126 | 125 | }); |
127 | 126 |
|
128 | | - RegisterServiceBus(services); |
129 | | - services.AddSingleton<IEventBus, EventBusRabbitMQ>(); |
130 | | - services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>(); |
131 | | - services.AddTransient<UserCheckoutAcceptedIntegrationEventHandler>(); |
132 | | - services.AddTransient<IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>, OrderProcessSaga>(); |
133 | | - services.AddTransient<OrderStockConfirmedIntegrationEventHandler>(); |
134 | | - services.AddTransient<OrderStockNotConfirmedIntegrationEventHandler>(); |
| 127 | + RegisterServiceBus(services); |
135 | 128 | services.AddOptions(); |
136 | 129 |
|
137 | 130 | //configure autofac |
@@ -176,36 +169,24 @@ private void RegisterServiceBus(IServiceCollection services) |
176 | 169 | { |
177 | 170 | services.AddSingleton<IEventBus, EventBusRabbitMQ>(); |
178 | 171 | services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>(); |
179 | | - |
180 | | - services.AddTransient<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>(); |
181 | 172 | services.AddTransient<IIntegrationEventHandler<ConfirmGracePeriodCommand>, OrderProcessSaga>(); |
182 | | - services.AddTransient<IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>, |
183 | | - OrderStockConfirmedIntegrationEventHandler>(); |
184 | | - services.AddTransient<IIntegrationEventHandler<OrderStockNotConfirmedIntegrationEvent>, |
185 | | - OrderStockNotConfirmedIntegrationEventHandler>(); |
186 | | - services.AddTransient<IIntegrationEventHandler<OrderPaymentFailedIntegrationEvent>, |
187 | | - OrderPaymentFailedIntegrationEventHandler>(); |
188 | | - services.AddTransient<IIntegrationEventHandler<OrderPaymentSuccededIntegrationEvent>, |
189 | | - OrderPaymentSuccededIntegrationEventHandler>(); |
| 173 | + services.AddTransient<UserCheckoutAcceptedIntegrationEventHandler>(); |
| 174 | + services.AddTransient<OrderStockConfirmedIntegrationEventHandler>(); |
| 175 | + services.AddTransient<OrderStockNotConfirmedIntegrationEventHandler>(); |
| 176 | + services.AddTransient<OrderPaymentFailedIntegrationEventHandler>(); |
| 177 | + services.AddTransient<OrderPaymentSuccededIntegrationEventHandler>(); |
190 | 178 | } |
191 | 179 |
|
192 | 180 | private void ConfigureEventBus(IApplicationBuilder app) |
193 | 181 | { |
194 | 182 | var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>(); |
195 | 183 |
|
196 | | - eventBus.Subscribe<UserCheckoutAcceptedIntegrationEvent, IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>(); |
197 | 184 | eventBus.Subscribe<ConfirmGracePeriodCommand, IIntegrationEventHandler<ConfirmGracePeriodCommand>>(); |
198 | | - eventBus.Subscribe<OrderStockConfirmedIntegrationEvent, IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>>(); |
199 | | - eventBus.Subscribe<OrderStockNotConfirmedIntegrationEvent, IIntegrationEventHandler<OrderStockNotConfirmedIntegrationEvent>>(); |
200 | | - eventBus.Subscribe<OrderPaymentFailedIntegrationEvent, IIntegrationEventHandler<OrderPaymentFailedIntegrationEvent>>(); |
201 | | - eventBus.Subscribe<OrderPaymentSuccededIntegrationEvent, IIntegrationEventHandler<OrderPaymentSuccededIntegrationEvent>>(); |
202 | | - eventBus.Subscribe<UserCheckoutAcceptedIntegrationEvent, UserCheckoutAcceptedIntegrationEventHandler>(); |
203 | | - |
204 | | - eventBus.Subscribe<ConfirmGracePeriodCommandMsg, IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>>(); |
205 | | - |
| 185 | + eventBus.Subscribe<UserCheckoutAcceptedIntegrationEvent, UserCheckoutAcceptedIntegrationEventHandler>(); |
206 | 186 | eventBus.Subscribe<OrderStockConfirmedIntegrationEvent, OrderStockConfirmedIntegrationEventHandler>(); |
207 | | - |
208 | 187 | eventBus.Subscribe<OrderStockNotConfirmedIntegrationEvent, OrderStockNotConfirmedIntegrationEventHandler>(); |
| 188 | + eventBus.Subscribe<OrderPaymentFailedIntegrationEvent, OrderPaymentFailedIntegrationEventHandler>(); |
| 189 | + eventBus.Subscribe<OrderPaymentSuccededIntegrationEvent, OrderPaymentSuccededIntegrationEventHandler>(); |
209 | 190 | } |
210 | 191 |
|
211 | 192 | protected virtual void ConfigureAuth(IApplicationBuilder app) |
|
0 commit comments