From b8ccc2d22a70a615d0338c04adda8486ea23ce34 Mon Sep 17 00:00:00 2001 From: gong yanhui Date: Tue, 14 Aug 2018 09:51:39 +0800 Subject: [PATCH] solve continue send message error bugs --- .../IntegrationEvents/CatalogIntegrationEventService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs index 1b82251e3..9f0bb72c1 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs @@ -24,13 +24,12 @@ namespace Catalog.API.IntegrationEvents _catalogContext = catalogContext ?? throw new ArgumentNullException(nameof(catalogContext)); _integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory)); _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); - _eventLogService = _integrationEventLogServiceFactory(_catalogContext.Database.GetDbConnection()); } public async Task PublishThroughEventBusAsync(IntegrationEvent evt) { _eventBus.Publish(evt); - + var _eventLogService = _integrationEventLogServiceFactory(_catalogContext.Database.GetDbConnection()); await _eventLogService.MarkEventAsPublishedAsync(evt); } @@ -42,6 +41,7 @@ namespace Catalog.API.IntegrationEvents .ExecuteAsync(async () => { // Achieving atomicity between original catalog database operation and the IntegrationEventLog thanks to a local transaction await _catalogContext.SaveChangesAsync(); + var _eventLogService = _integrationEventLogServiceFactory(_catalogContext.Database.GetDbConnection()); await _eventLogService.SaveEventAsync(evt, _catalogContext.Database.CurrentTransaction.GetDbTransaction()); }); }