using MassTransit; using LCU.Api.Internal.MaidBotLib.Models; using ReserveManagementSystemLib.Models; using ReserveManagementSystemApi.Services; namespace ReserveManagementSystemApi.Consumers; public class RmsActiveImportConsumer : IConsumer { private readonly IServiceScopeFactory _scopeFactory; public RmsActiveImportConsumer(IServiceScopeFactory scopeFactory) { _scopeFactory = scopeFactory; } public async Task Consume(ConsumeContext context) { try { Log.Debug("Starting RmsActiveImportConsumer."); using var scope = _scopeFactory.CreateScope(); await Task.Run(async () => await scope.ServiceProvider.GetRequiredService().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; } } }