Create ensure connection with webscoket
This commit is contained in:
parent
545bb96b9d
commit
1657cb2b61
|
|
@ -44,6 +44,30 @@ public static class RabbitMqManager
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean EnsureConnected(StatusMessage currentSalimaxState, string? s3Bucket, string vpnServerIp)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_connection == null || !_connection.IsOpen ||
|
||||||
|
_channel == null || _channel.IsClosed)
|
||||||
|
{
|
||||||
|
Console.WriteLine("⚠ RabbitMQ connection lost. Reconnecting...");
|
||||||
|
|
||||||
|
_connection?.Dispose();
|
||||||
|
_channel?.Dispose();
|
||||||
|
|
||||||
|
return SubscribeToQueue(currentSalimaxState, s3Bucket, vpnServerIp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("❌ Error while ensuring RabbitMQ connection: " + ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void InformMiddleware(StatusMessage status)
|
public static void InformMiddleware(StatusMessage status)
|
||||||
{
|
{
|
||||||
var message = JsonSerializer.Serialize(status);
|
var message = JsonSerializer.Serialize(status);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue