Remove MarkEventAsPublishedAsync call from PublishThroughEventBusAsync

This commit is contained in:
Christian Arenas 2017-05-09 15:36:45 +02:00
parent e0d67bf884
commit 9382813905
4 changed files with 11 additions and 18 deletions

View File

@ -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);
}
}

View File

@ -11,25 +11,16 @@
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)
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);
}
}
}

View File

@ -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<ILoggerFactory>();
Configure(logger);
var sagaManagerService = serviceProvider
.GetRequiredService<ISagaManagerService>();

View File

@ -43,6 +43,7 @@ namespace SagaManager.Services
{
try
{
_logger.LogInformation("SagaManager Client is trying to connect to database server");
conn.Open();
orderIds = conn.Query<int>(
@"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);
}
}
}