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