Put try-catch statement when trying to connect to the queue for the first time
This commit is contained in:
parent
30a3a05de0
commit
511c3080a6
|
@ -298,14 +298,21 @@ internal static class Program
|
|||
|
||||
private static void SubscribeToQueue(SalimaxAlarmState currentSalimaxState, String? s3Bucket)
|
||||
{
|
||||
_factory = new ConnectionFactory { HostName = VpnServerIp };
|
||||
_connection = _factory.CreateConnection();
|
||||
_channel = _connection.CreateModel();
|
||||
_channel.QueueDeclare(queue: "statusQueue", durable: false, exclusive: false, autoDelete: false, arguments: null);
|
||||
Console.WriteLine("The controller sends its status to the middleware for the first time");
|
||||
if (s3Bucket != null) InformMiddleware(s3Bucket, (Int32)currentSalimaxState);
|
||||
try
|
||||
{
|
||||
_factory = new ConnectionFactory { HostName = VpnServerIp };
|
||||
_connection = _factory.CreateConnection();
|
||||
_channel = _connection.CreateModel();
|
||||
_channel.QueueDeclare(queue: "statusQueue", durable: false, exclusive: false, autoDelete: false, arguments: null);
|
||||
Console.WriteLine("The controller sends its status to the middleware for the first time");
|
||||
if (s3Bucket != null) InformMiddleware(s3Bucket, (Int32)currentSalimaxState);
|
||||
|
||||
_subscribedToQueue = true;
|
||||
_subscribedToQueue = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("An error occurred while connecting to the RabbitMQ queue: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static IPAddress FindVpnIp()
|
||||
|
|
Loading…
Reference in New Issue