public async Task SaveEventAndMovieContextChangesAsync(Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events.IntegrationEvent evt) { //Use of an EF Core resiliency strategy when using multiple DbContexts within an explicit BeginTransaction(): //See: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency await ResilientTransaction.New(_movieContext) .ExecuteAsync(async() => { // Achieving atomicity between original catalog database operation and the IntegrationEventLog thanks to a local transaction await _movieContext.SaveChangesAsync(); await _eventLogService.SaveEventAsync(evt, _movieContext.Database.CurrentTransaction.GetDbTransaction()); }); }
public async Task PublishThroughEventBusAsync(Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events.IntegrationEvent evt) { _eventBus.Publish(evt); await _eventLogService.MarkEventAsPublishedAsync(evt); }