private static IEnumerable <DiagnosticInfo> CheckConstructor(IMessageAdapterConstructor constructor) { try { var adapters = constructor.CreateAll(true) .Where(x => x.Configuration.IsHealthCheck) .ToList(); var result = new List <DiagnosticInfo>(adapters.Count); foreach (var messageAdapter in adapters) { var itemConfig = messageAdapter.Configuration; try { messageAdapter.Connect(); messageAdapter.Disconnect(); Logger.LogDiagnostic($"Diagnostic of messaging queue with id {itemConfig.Id} has been done successfully"); result.Add(new DiagnosticInfo(itemConfig.Id, itemConfig.Server)); } catch (Exception e) { Logger.LogDiagnostic($"Diagnostic of messaging queue with id {itemConfig.Id} has been failed with error: {e}"); result.Add(new DiagnosticInfo(itemConfig.Id, itemConfig.Server, DiagnosticStatus.QueueError, string.Empty, e.ToString())); } } return(result); } catch (Exception e) { Logger.LogDiagnostic($"Diagnostic of messaging constructor has been failed with error: {e}"); return(new List <DiagnosticInfo> { new DiagnosticInfo("constructor", null, DiagnosticStatus.ConfigError, string.Empty, e.ToString()) }); } }
public MessagingConnectionCheckerBuilder WithConstructor(IMessageAdapterConstructor constructor) { _constructors.AddLast(constructor); return(this); }