/// <summary> /// Runs the actual Gather and Scatter algorithm. /// </summary> /// <typeparam name="T">The type of payload wanting to be sent.</typeparam> /// <param name="message">The message wanting to be sent to all queues.</param> public void Run <T>(AggregationMessage <T> message) where T : class { _aggregationId = message.AggregationId; _receiver.Run(); foreach (var rabbitMqProducer in _producers) { try { rabbitMqProducer.SendObject(message); } catch { // Negate the failed sends. //TODO: Later store this somewhere and return it back to the user. } } _timer.Interval = 60_000d; _timer.Elapsed += TimerOnElapsed; _timer.Start(); }
/// <summary> /// Runs the main health checking logic. /// </summary> /// <param name="args">Arguments provided by the commandline.</param> public static void Main(string[] args) { var services = GetServices(); var outgoingQueues = services.Select(x => x.ApplicationId); var faker = new Faker(); _scatterGatter = new RabbitMqScatterGatter(outgoingQueues, StaticQueues.HealthCheckReply) { EndingAction = LogStatus }; var message = new AggregationMessage <string> { Payload = "Please report health check", // Generate a pseudorandom Aggregation Id for all the messages. AggregationId = faker.Random.AlphaNumeric(10) }; Log.Information("Ready, press enter to send a message"); Console.ReadLine(); _scatterGatter.Run(message); Console.ReadLine(); }