Standard names fix
This commit is contained in:
		
							parent
							
								
									4371e4860b
								
							
						
					
					
						commit
						d7bf2c9d7b
					
				| @ -1,16 +0,0 @@ | ||||
| namespace SagaManager.IntegrationEvents | ||||
| { | ||||
|     using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; | ||||
|     using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; | ||||
|     using System; | ||||
| 
 | ||||
|     public class ConfirmGracePeriodEvent : IConfirmGracePeriodEvent | ||||
|     { | ||||
|         private readonly IEventBus _eventBus; | ||||
| 
 | ||||
|         public ConfirmGracePeriodEvent(IEventBus eventBus) =>  | ||||
|             _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); | ||||
| 
 | ||||
|         public void PublishThroughEventBus(IntegrationEvent evt) => _eventBus.Publish(evt); | ||||
|     } | ||||
| } | ||||
| @ -5,10 +5,10 @@ | ||||
|     // Integration Events notes:  | ||||
|     // An Event is “something that has happened in the past”, therefore its name has to be    | ||||
|     // An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems. | ||||
|     public class ConfirmGracePeriodIntegrationEvent : IntegrationEvent | ||||
|     public class ConfirmGracePeriodCommandMsg : IntegrationEvent | ||||
|     { | ||||
|         public int OrderId { get;} | ||||
| 
 | ||||
|         public ConfirmGracePeriodIntegrationEvent(int orderId) => OrderId = orderId; | ||||
|         public ConfirmGracePeriodCommandMsg(int orderId) => OrderId = orderId; | ||||
|     } | ||||
| } | ||||
| @ -1,9 +0,0 @@ | ||||
| namespace SagaManager.IntegrationEvents | ||||
| { | ||||
|     using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; | ||||
| 
 | ||||
|     public interface IConfirmGracePeriodEvent | ||||
|     { | ||||
|         void PublishThroughEventBus(IntegrationEvent evt); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,10 @@ | ||||
| namespace SagaManager.IntegrationEvents | ||||
| { | ||||
|     using System.Threading.Tasks; | ||||
|     using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; | ||||
| 
 | ||||
|     public interface ISagaManagingIntegrationEventService | ||||
|     { | ||||
|         Task PublishThroughEventBusAsync(IntegrationEvent evt); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,35 @@ | ||||
| namespace SagaManager.IntegrationEvents | ||||
| { | ||||
|     using System.Data.Common; | ||||
|     using System.Threading.Tasks; | ||||
|     using Microsoft.EntityFrameworkCore; | ||||
|     using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; | ||||
|     using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; | ||||
|     using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services; | ||||
|     using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; | ||||
|     using System; | ||||
| 
 | ||||
|     public class SagaManagingIntegrationEventService : ISagaManagingIntegrationEventService | ||||
|     { | ||||
|         private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory; | ||||
|         private readonly IEventBus _eventBus; | ||||
|         private readonly OrderingContext _orderingContext; | ||||
|         private readonly IIntegrationEventLogService _eventLogService; | ||||
| 
 | ||||
|         public SagaManagingIntegrationEventService(IEventBus eventBus, OrderingContext orderingContext, | ||||
|             Func<DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory) | ||||
|         { | ||||
|             _orderingContext = orderingContext ?? throw new ArgumentNullException(nameof(orderingContext)); | ||||
|             _integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory)); | ||||
|             _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); | ||||
|             _eventLogService = _integrationEventLogServiceFactory(_orderingContext.Database.GetDbConnection()); | ||||
|         } | ||||
| 
 | ||||
|         public async Task PublishThroughEventBusAsync(IntegrationEvent evt) | ||||
|         { | ||||
|             _eventBus.Publish(evt); | ||||
| 
 | ||||
|             await _eventLogService.MarkEventAsPublishedAsync(evt); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -55,7 +55,7 @@ namespace SagaManager | ||||
|                 .AddOptions() | ||||
|                 .Configure<SagaManagerSettings>(Configuration) | ||||
|                 .AddSingleton<ISagaManagerService, SagaManagerService>() | ||||
|                 .AddSingleton<IConfirmGracePeriodEvent, ConfirmGracePeriodEvent>() | ||||
|                 .AddSingleton<ISagaManagingIntegrationEventService, SagaManagingIntegrationEventService>() | ||||
|                 .AddSingleton<IEventBus, EventBusRabbitMQ>() | ||||
|                 .AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>() | ||||
|                 .AddSingleton<IRabbitMQPersistentConnection>(sp => | ||||
|  | ||||
| @ -21,6 +21,8 @@ | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" /> | ||||
|     <ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" /> | ||||
|     <ProjectReference Include="..\..\..\BuildingBlocks\EventBus\IntegrationEventLogEF\IntegrationEventLogEF.csproj" /> | ||||
|     <ProjectReference Include="..\..\Ordering\Ordering.Infrastructure\Ordering.Infrastructure.csproj" /> | ||||
|   </ItemGroup> | ||||
| 
 | ||||
|   <ItemGroup> | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| using System; | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.Extensions.Logging; | ||||
| 
 | ||||
| namespace SagaManager.Services | ||||
| @ -13,15 +14,15 @@ namespace SagaManager.Services | ||||
|     public class SagaManagerService : ISagaManagerService | ||||
|     { | ||||
|         private readonly SagaManagerSettings _settings; | ||||
|         private readonly IConfirmGracePeriodEvent _confirmGracePeriodEvent; | ||||
|         private readonly ISagaManagingIntegrationEventService _sagaManagingIntegrationEventService; | ||||
|         private readonly ILogger<SagaManagerService> _logger; | ||||
| 
 | ||||
|         public SagaManagerService(IOptions<SagaManagerSettings> settings, | ||||
|             IConfirmGracePeriodEvent confirmGracePeriodEvent, | ||||
|             ISagaManagingIntegrationEventService sagaManagingIntegrationEventService, | ||||
|             ILogger<SagaManagerService> logger) | ||||
|         { | ||||
|             _settings = settings.Value; | ||||
|             _confirmGracePeriodEvent = confirmGracePeriodEvent; | ||||
|             _sagaManagingIntegrationEventService = sagaManagingIntegrationEventService; | ||||
|             _logger = logger; | ||||
|         } | ||||
| 
 | ||||
| @ -59,12 +60,12 @@ namespace SagaManager.Services | ||||
|             return orderIds; | ||||
|         } | ||||
| 
 | ||||
|         private void Publish(int orderId) | ||||
|         private async Task Publish(int orderId) | ||||
|         { | ||||
|             var confirmGracePeriodEvent = new ConfirmGracePeriodIntegrationEvent(orderId); | ||||
|             var confirmGracePeriodEvent = new ConfirmGracePeriodCommandMsg(orderId); | ||||
| 
 | ||||
|             // Publish through the Event Bus | ||||
|            _confirmGracePeriodEvent.PublishThroughEventBus(confirmGracePeriodEvent); | ||||
|             await _sagaManagingIntegrationEventService.PublishThroughEventBusAsync(confirmGracePeriodEvent); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user