Skip to content

Commit

Permalink
#273 Wrap IOutboxMigrationService resolution in a scope
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Pringle <[email protected]>
  • Loading branch information
EtherZa authored and zarusz committed Jun 27, 2024
1 parent 0981d8d commit f961a62
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,20 @@ public Task OnBusLifecycle(MessageBusLifecycleEventType eventType, IMessageBus b

private static async Task MigrateSchema(IServiceProvider serviceProvider, CancellationToken cancellationToken)
{
var scope = serviceProvider.CreateScope();
try
{
var outboxMigrationService = serviceProvider.GetRequiredService<IOutboxMigrationService>();
var outboxMigrationService = scope.ServiceProvider.GetRequiredService<IOutboxMigrationService>();
await outboxMigrationService.Migrate(cancellationToken);
}
catch (Exception e)
{
throw new MessageBusException("Outbox schema migration failed", e);
}
finally
{
await ((IAsyncDisposable)scope).DisposeAsync();
}
}

private Task EnsureMigrateSchema(IServiceProvider serviceProvider, CancellationToken cancellationToken)
Expand Down

0 comments on commit f961a62

Please sign in to comment.