Reattempt RabbitMQ connection on first attempt

This commit is contained in:
Luck 2023-05-01 10:00:05 +01:00
parent cfe0d806a1
commit 9640271260
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -156,8 +156,19 @@ public class RabbitMQMessenger implements Messenger {
this.plugin.getLogger().info("RabbitMQ pubsub connection re-established");
}
return true;
} catch (Exception ignored) {
return false;
} catch (Exception e) {
if (firstStartup) {
this.plugin.getLogger().warn("Unable to connect to RabbitMQ, waiting for 5 seconds then retrying...", e);
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
return checkAndReopenConnection(false);
} else {
this.plugin.getLogger().severe("Unable to connect to RabbitMQ", e);
return false;
}
}
}