I am writing a C# Console app (Windows scheduled task) to monitor the status of Rabbit MQ. So in case the the queue is down (service down, connection timeout, or any other reason) it will send a notification mail. I have used RabbitMQ .Net client (version 4.1.1). Basically I am checking if the CreateConnection() is successfull.
private static void CheckRabbitMQStatus()
{
ConnectionFactory factory = new ConnectionFactory();
factory.Uri = "amqp://guest:guest@testserver:5672/";
IConnection conn = null;
try
{
conn = factory.CreateConnection();
conn.Close();
conn.Dispose();
}
catch (Exception ex)
{
if (ex.Message == "None of the specified endpoints were reachable")
{
//send mail MQ is down
}
}
}
Is this the right approach to achieve this? There are several tools and plugins available for Rabbit MQ but I want a simple solution in C#.
ex
? Comparing the message might break in later releases ... – user57508RabbitMQ.Client.Exceptions.BrokerUnreachableException
-- That being said, the message is the same as of August 2020 ¯\_(ツ)_/¯ – anon