private async Task ProcessResponse(GatewayResponse response) { try { using (var serviceScope = Services.CreateScope()) { { var commandQueues = serviceScope.ServiceProvider.GetRequiredService <CommandQueues>(); commandQueues.TryPostResponse(gatewayId, response); } if (!response.HasError()) { var responseProcessor = serviceScope.ServiceProvider.GetRequiredService <GatewayResponseProcessor>(); await responseProcessor.ProcessResponse(response.GetMessage()); } } } catch (Exception e) { Console.WriteLine($"Unknown exception during message processing. {e.Message}"); } }