Add transaction support between services

This commit is contained in:
2025-10-27 18:09:09 +09:00
parent 6b3733001a
commit 9e526c54fa
11 changed files with 75 additions and 44 deletions

View File

@ -25,19 +25,18 @@ namespace Hcs.WebApp.BackgroundServices
InitializeClient();
var scope = scopeFactory.CreateScope();
var headquartersService = scope.ServiceProvider.GetRequiredService<HeadquartersService>();
while (!stoppingToken.IsCancellationRequested)
{
while (state.TryDequeueOperation(out var operation))
{
if (stoppingToken.IsCancellationRequested) return;
var scope = scopeFactory.CreateScope();
var headquartersService = scope.ServiceProvider.GetRequiredService<HeadquartersService>();
var messageGuid = string.Empty;
try
{
var executor = executorFactory.CreateExecutor(client, operation);
var executor = executorFactory.CreateExecutor(scope, client, operation);
await headquartersService.SetOperationStarted(operation.Id);
messageGuid = await executor.ExecuteAsync(stoppingToken);
}