Add transaction support between services
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user