Updating
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MassTransit;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using ApiResponse = LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Consumers;
|
||||
|
||||
public class ResponseConsumer : IConsumer<ApiResponse.Response>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ResponseConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ApiResponse.Response> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(() => scope.ServiceProvider.GetRequiredService<IArchiveCompletionService>().HandleReportArchiveCompletedRequest(context.Message));
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Fatal(exception, $"Unexpected Failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user