public string GetAgentById(int id) { string response = ResponseNone; MessageRouterManager messageRouterManager = WebApiConfig.MessageRouterManager; IRoutingDataManager routingDataManager = messageRouterManager.RoutingDataManager; if (routingDataManager.GetAggregationParties().Count == 0 && routingDataManager.GetPendingRequests().Count > 0) { try { Party conversationClientParty = messageRouterManager.RoutingDataManager.GetPendingRequests().First(); messageRouterManager.RoutingDataManager.RemovePendingRequest(conversationClientParty); response = conversationClientParty.ToJsonString(); } catch (InvalidOperationException e) { System.Diagnostics.Debug.WriteLine($"Failed to handle a pending request: {e.Message}"); } } return(response); }