Adding
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
using MassTransit;
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemApi.Services;
|
||||
|
||||
namespace ReserveManagementSystemApi.Consumers;
|
||||
|
||||
public class RmsActiveImportConsumer : IConsumer<RmsActiveImportRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public RmsActiveImportConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<RmsActiveImportRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting RmsActiveImportConsumer.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IRmsActiveLoanService>().HandleRmsActiveImportRequest(context.Message));
|
||||
Log.Debug("Ending RmsActiveImportConsumer.");
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Unexpected RmsActiveImportConsumer Failure. " +
|
||||
$"The RmsActiveImportRequest is placed on ReserveManagementSystemApi.ActiveImport_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user