Skip to content

Commit 9382813

Browse files
committed
Remove MarkEventAsPublishedAsync call from PublishThroughEventBusAsync
1 parent e0d67bf commit 9382813

4 files changed

Lines changed: 11 additions & 18 deletions

File tree

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
namespace SagaManager.IntegrationEvents
22
{
3-
using System.Threading.Tasks;
43
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
54

65
public interface ISagaManagingIntegrationEventService
76
{
8-
Task PublishThroughEventBusAsync(IntegrationEvent evt);
7+
void PublishThroughEventBusAsync(IntegrationEvent evt);
98
}
109
}

src/Services/SagaManager/SagaManager/IntegrationEvents/SagaManagingIntegrationEventService.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,16 @@
1111

1212
public class SagaManagingIntegrationEventService : ISagaManagingIntegrationEventService
1313
{
14-
private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory;
1514
private readonly IEventBus _eventBus;
16-
private readonly OrderingContext _orderingContext;
17-
private readonly IIntegrationEventLogService _eventLogService;
1815

19-
public SagaManagingIntegrationEventService(IEventBus eventBus, OrderingContext orderingContext,
20-
Func<DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory)
16+
public SagaManagingIntegrationEventService(IEventBus eventBus)
2117
{
22-
_orderingContext = orderingContext ?? throw new ArgumentNullException(nameof(orderingContext));
23-
_integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory));
2418
_eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
25-
_eventLogService = _integrationEventLogServiceFactory(_orderingContext.Database.GetDbConnection());
2619
}
2720

28-
public async Task PublishThroughEventBusAsync(IntegrationEvent evt)
21+
public void PublishThroughEventBusAsync(IntegrationEvent evt)
2922
{
3023
_eventBus.Publish(evt);
31-
32-
await _eventLogService.MarkEventAsPublishedAsync(evt);
3324
}
3425
}
3526
}

src/Services/SagaManager/SagaManager/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
1+
using System.Reflection;
2+
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
3+
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
4+
using Microsoft.EntityFrameworkCore;
25
using SagaManager.IntegrationEvents;
36

47
namespace SagaManager
@@ -28,7 +31,6 @@ public static void Main(string[] args)
2831
var logger = serviceProvider.GetService<ILoggerFactory>();
2932
Configure(logger);
3033

31-
3234
var sagaManagerService = serviceProvider
3335
.GetRequiredService<ISagaManagerService>();
3436

src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private IEnumerable<int> GetFinishedGracePeriodOrders()
4343
{
4444
try
4545
{
46+
_logger.LogInformation("SagaManager Client is trying to connect to database server");
4647
conn.Open();
4748
orderIds = conn.Query<int>(
4849
@"SELECT Id FROM [Microsoft.eShopOnContainers.Services.OrderingDb].[ordering].[orders]
@@ -52,20 +53,20 @@ WHERE DATEDIFF(hour, [OrderDate], GETDATE()) >= @GracePeriod
5253
}
5354
catch (SqlException exception)
5455
{
55-
_logger.LogError(exception.Message);
56+
_logger.LogCritical($"FATAL ERROR: Database connections could not be opened: {exception.Message}");
5657
}
5758

5859
}
5960

6061
return orderIds;
6162
}
6263

63-
private async Task Publish(int orderId)
64+
private void Publish(int orderId)
6465
{
6566
var confirmGracePeriodEvent = new ConfirmGracePeriodCommandMsg(orderId);
6667

6768
// Publish through the Event Bus
68-
await _sagaManagingIntegrationEventService.PublishThroughEventBusAsync(confirmGracePeriodEvent);
69+
_sagaManagingIntegrationEventService.PublishThroughEventBusAsync(confirmGracePeriodEvent);
6970
}
7071
}
7172
}

0 commit comments

Comments
 (0)