Browse Source

Remove MarkEventAsPublishedAsync call from PublishThroughEventBusAsync

pull/809/head
Christian Arenas 7 years ago
parent
commit
9382813905
4 changed files with 11 additions and 18 deletions
  1. +1
    -2
      src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs
  2. +2
    -11
      src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs
  3. +4
    -2
      src/Services/SagaManager/SagaManager/Program.cs
  4. +4
    -3
      src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs

+ 1
- 2
src/Services/SagaManager/SagaManager/IntegrationEvents/ISagaManagingIntegrationEventService.cs 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);
}
}

+ 2
- 11
src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs 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);
}
}
}

+ 4
- 2
src/Services/SagaManager/SagaManager/Program.cs 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>();


+ 4
- 3
src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs 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);
}
}
}

Loading…
Cancel
Save