I have this code just below that makes a connection to my server. I would like to perform a check of the status of my server through a method that connects to that server, how can I implement this?
public class ConnectionRabbitmqFactoryConsumer {
private static final Logger LOGGER =
SaveLog.lauchLog(ReadConfigDatabase.class.getName());
public static ConnectionFactory getConnection() {
try {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("192.168.120.150");
factory.setUsername("adm");
factory.setPassword("adm");
factory.setPort(5672);
return factory;
} catch (Exception e) {
e.printStackTrace(System.err);
LOGGER.error("error conection rabbitmq ");
}
return null;
}
}
This is an application that sends the message from my server / client. The code below, prepares to send this message, before sending it drops in this getConnection (), to see if everything is ok with my server.
@Override
public void run() {
try {
//Execultar tarefas assincronas
ExecutorService threader = Executors.newFixedThreadPool(20);
Connection connection = ConnectionRabbitmqFactoryConsumer.getConnection().newConnection(threader);
.......