diff --git a/src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs b/src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs index d1eb3cb5d..570618b91 100644 --- a/src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs +++ b/src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs @@ -1,10 +1,9 @@ namespace SagaManager.IntegrationEvents { - using System.Threading.Tasks; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; public interface ISagaManagingIntegrationEventService { - Task PublishThroughEventBusAsync(IntegrationEvent evt); + void PublishThroughEventBusAsync(IntegrationEvent evt); } } \ No newline at end of file diff --git a/src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs b/src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs index c040143ad..825977a25 100644 --- a/src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs +++ b/src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs @@ -11,25 +11,16 @@ public class SagaManagingIntegrationEventService : ISagaManagingIntegrationEventService { - private readonly Func _integrationEventLogServiceFactory; private readonly IEventBus _eventBus; - private readonly OrderingContext _orderingContext; - private readonly IIntegrationEventLogService _eventLogService; - public SagaManagingIntegrationEventService(IEventBus eventBus, OrderingContext orderingContext, - Func integrationEventLogServiceFactory) + public SagaManagingIntegrationEventService(IEventBus eventBus) { - _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) + public void PublishThroughEventBusAsync(IntegrationEvent evt) { _eventBus.Publish(evt); - - await _eventLogService.MarkEventAsPublishedAsync(evt); } } } \ No newline at end of file diff --git a/src/Services/SagaManager/SagaManager/Program.cs b/src/Services/SagaManager/SagaManager/Program.cs index 2152a046e..832aa0145 100644 --- a/src/Services/SagaManager/SagaManager/Program.cs +++ b/src/Services/SagaManager/SagaManager/Program.cs @@ -1,4 +1,7 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; +using System.Reflection; +using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; +using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; +using Microsoft.EntityFrameworkCore; using SagaManager.IntegrationEvents; namespace SagaManager @@ -28,7 +31,6 @@ namespace SagaManager var logger = serviceProvider.GetService(); Configure(logger); - var sagaManagerService = serviceProvider .GetRequiredService(); diff --git a/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs b/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs index 32743df03..88c186d93 100644 --- a/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs +++ b/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs @@ -43,6 +43,7 @@ namespace SagaManager.Services { try { + _logger.LogInformation("SagaManager Client is trying to connect to database server"); conn.Open(); orderIds = conn.Query( @"SELECT Id FROM [Microsoft.eShopOnContainers.Services.OrderingDb].[ordering].[orders] @@ -52,7 +53,7 @@ namespace SagaManager.Services } catch (SqlException exception) { - _logger.LogError(exception.Message); + _logger.LogCritical($"FATAL ERROR: Database connections could not be opened: {exception.Message}"); } } @@ -60,12 +61,12 @@ namespace SagaManager.Services return orderIds; } - private async Task Publish(int orderId) + private void Publish(int orderId) { var confirmGracePeriodEvent = new ConfirmGracePeriodCommandMsg(orderId); // Publish through the Event Bus - await _sagaManagingIntegrationEventService.PublishThroughEventBusAsync(confirmGracePeriodEvent); + _sagaManagingIntegrationEventService.PublishThroughEventBusAsync(confirmGracePeriodEvent); } } } \ No newline at end of file