/** * Constructor has to be hidden */ private Messenger() { rabbitMQ = RabbitMQPublisher.getInstance(); }
/** * Connect to RabbitMQ with Publisher and Consumer */ private static void checkAndSetupRabbitMQ() { // establish connections with RabbitMQ exchanges and queues if (RabbitMQPublisher.getInstance() == null) { String log = "Couldn't establish connection with RabbitMQ Publisher"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } if (!ConsumeManager.startDataAndCommandProcessing()) { String log = "Couldn't establish connection with RabbitMQ Consumer"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } outputProgressBar(); }
/** * Connect to RabbitMQ with Publisher and Consumer */ private static void checkAndSetupRabbitMQ() { // establish connections with RabbitMQ exchanges and queues if (RabbitMQPublisher.getInstance() == null) { String log = "Couldn't establish connection with RabbitMQ Publisher"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } if (!ConsumeManager.startDataAndCommandProcessing()) { String log = "Couldn't establish connection with RabbitMQ Consumer"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } outputProgressBar(); }
/** * Connect to RabbitMQ with Publisher and Consumer */ private static void checkAndSetupRabbitMQ() { // establish connections with RabbitMQ exchanges and queues if (RabbitMQPublisher.getInstance() == null) { String log = "Couldn't establish connection with RabbitMQ Publisher"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } if (!ConsumeManager.startDataAndCommandProcessing()) { String log = "Couldn't establish connection with RabbitMQ Consumer"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } outputProgressBar(); }
/** * Connect to RabbitMQ with Publisher and Consumer */ private static void checkAndSetupRabbitMQ() { // establish connections with RabbitMQ exchanges and queues if (RabbitMQPublisher.getInstance() == null) { String log = "Couldn't establish connection with RabbitMQ Publisher"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } if (!ConsumeManager.startConsumption()) { String log = "Couldn't establish connection with RabbitMQ Consumer"; logger.error(log); System.err.println(log); System.exit(ERR_RABBITMQ); } outputProgressBar(); }
/** * Broadcast message using RabbitMQ * @param content of the message */ public static boolean broadcast(Object content) { RabbitMQPublisher rabbitMQ = RabbitMQPublisher.getInstance(); if (rabbitMQ != null) { return rabbitMQ.broadcast(content); } else { DispatchLogger.log("RabbitMQ is not properly configured, therefore it is not possible to publish any messages. Please consult logs and double check configuration files"); return false; } } }
/** * Publish message using RabbitMQ * @param content of the message * @param routing key */ public static boolean publish(Object content, String routing) { RabbitMQPublisher rabbitMQ = RabbitMQPublisher.getInstance(); if (rabbitMQ != null) { return rabbitMQ.publish(content, routing); } else { DispatchLogger.log("RabbitMQ is not properly configured, therefore it is not possible to publish any messages. Please consult logs and double check configuration files"); return false; } }
/** * Broadcast message using RabbitMQ * @param content of the message */ public static boolean broadcast(Object content) { RabbitMQPublisher rabbitMQ = RabbitMQPublisher.getInstance(); if (rabbitMQ != null) { return rabbitMQ.broadcast(content); } else { DispatchLogger.log("RabbitMQ is not properly configured, therefore it is not possible to publish any messages. Please consult logs and double check configuration files"); return false; } } }
/** * Broadcast message using RabbitMQ * @param content of the message */ public static boolean broadcast(Object content) { RabbitMQPublisher rabbitMQ = RabbitMQPublisher.getInstance(); if (rabbitMQ != null) { return rabbitMQ.broadcast(content); } else { DispatchLogger.log("RabbitMQ is not properly configured, therefore it is not possible to publish any messages. Please consult logs and double check configuration files"); return false; } } }
/** * Publish message using RabbitMQ * @param content of the message * @param routing key */ public static boolean publish(Object content, String routing) { RabbitMQPublisher rabbitMQ = RabbitMQPublisher.getInstance(); if (rabbitMQ != null) { return rabbitMQ.publish(content, routing); } else { DispatchLogger.log("RabbitMQ is not properly configured, therefore it is not possible to publish any messages. Please consult logs and double check configuration files"); return false; } }
/** * Publish message using RabbitMQ * @param content of the message * @param routing key */ public static boolean publish(Object content, String routing) { RabbitMQPublisher rabbitMQ = RabbitMQPublisher.getInstance(); if (rabbitMQ != null) { return rabbitMQ.publish(content, routing); } else { DispatchLogger.log("RabbitMQ is not properly configured, therefore it is not possible to publish any messages. Please consult logs and double check configuration files"); return false; } }
@Override public void run() { try { // check the database connection whether it is alive if (new DbAccess().ping()) logger.trace("Health check: Database connection is alive"); else throw new Exception("Database is down"); // test whether we have live TCP connection to RabbitMQ listener if (RabbitMQListener.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Listener is alive"); else throw new Exception("RabbitMQ Listener is down"); // test our TCP connection to RabbitMQ Publisher if (RabbitMQPublisher.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Publisher is alive"); else throw new Exception("RabbitMQ Publisher is down"); // we passed all the tests HealthStatus.getInstance().setHealthy(); } catch (Exception e) { logger.trace(String.format("Health check: failed (%s)", e.getMessage())); // we couldn't access the InfluxDB HealthStatus.getInstance().setUnhealthy(e.getMessage()); } } }
@Override public void run() { try { // check the database connection whether it is alive if (new DbAccess().ping()) logger.trace("Health check: Database connection is alive"); else throw new Exception("Database is down"); // test whether we have live TCP connection to RabbitMQ listener if (RabbitMQListener.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Listener is alive"); else throw new Exception("RabbitMQ Listener is down"); // test our TCP connection to RabbitMQ Publisher if (RabbitMQPublisher.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Publisher is alive"); else throw new Exception("RabbitMQ Publisher is down"); // we passed all the tests HealthStatus.getInstance().setHealthy(); } catch (Exception e) { logger.trace(String.format("Health check: failed (%s)", e.getMessage())); // we couldn't access the InfluxDB HealthStatus.getInstance().setUnhealthy(e.getMessage()); } } }
@Override public void run() { try { // check the database connection whether it is alive if (new DbAccess().ping()) logger.trace("Health check: Database connection is alive"); else throw new Exception("Database is down"); // test whether we have live TCP connection to RabbitMQ listener if (RabbitMQListener.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Listener is alive"); else throw new Exception("RabbitMQ Listener is down"); // test our TCP connection to RabbitMQ Publisher if (RabbitMQPublisher.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Publisher is alive"); else throw new Exception("RabbitMQ Publisher is down"); // we passed all the tests HealthStatus.getInstance().setHealthy(); } catch (Exception e) { logger.trace(String.format("Health check: failed (%s)", e.getMessage())); // we couldn't access the InfluxDB HealthStatus.getInstance().setUnhealthy(e.getMessage()); } } }
@Override public void run() { try { // test database connection HibernateClient.getInstance().ping(); logger.trace("Health check: PostgreSQL is alive"); // test whether we have live TCP connection to RabbitMQ listener if (RabbitMQListener.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Listener is alive"); else throw new Exception("RabbitMQ Listener is down"); // test our TCP connection to RabbitMQ Publisher if (RabbitMQPublisher.getInstance().isConnected()) logger.trace("Health check: RabbitMQ Publisher is alive"); else throw new Exception("RabbitMQ Publisher is down"); // we passed all the tests HealthStatus.getInstance().setHealthy(); } catch (Exception e) { logger.trace(String.format("Health check: failed (%s)", e.getMessage())); // we couldn't access the InfluxDB HealthStatus.getInstance().setUnhealthy(e.getMessage()); } } }
/** * Restore the microservice */ protected synchronized void setHealthy() { // if not already healthy if (!healthy) { healthy = true; reason = null; resetWatch(); // stop remaining scheduled checks TaskExecutor.getInstance().shutDown(); // try to start publisher if (RabbitMQPublisher.getInstance() == null) { healthy = false; } // try to start consumer if (!ConsumeManager.startConsumption()) { healthy = false; // shut down publisher RabbitMQPublisher.shutDown(); } // schedule micro service check scheduleCheck(); } }
/** * Restore the microservice */ protected synchronized void setHealthy() { // if not already healthy if (!healthy) { healthy = true; reason = null; resetWatch(); // stop remaining scheduled checks TaskExecutor.getInstance().shutDown(); // try to start publisher if (RabbitMQPublisher.getInstance() == null) { healthy = false; } // try to start consumer if (!ConsumeManager.startDataAndCommandProcessing()) { healthy = false; // shut down publisher RabbitMQPublisher.shutDown(); } // schedule micro service check scheduleCheck(); } }
/** * Restore the microservice */ protected synchronized void setHealthy() { // if not already healthy if (!healthy) { healthy = true; reason = null; resetWatch(); // stop remaining scheduled checks TaskExecutor.getInstance().shutDown(); // try to start publisher if (RabbitMQPublisher.getInstance() == null) { healthy = false; } // try to start consumer if (!ConsumeManager.startDataAndCommandProcessing()) { healthy = false; // shut down publisher RabbitMQPublisher.shutDown(); } // schedule micro service check scheduleCheck(); } }
/** * Restore the microservice */ protected synchronized void setHealthy() { // if not already healthy if (!healthy) { healthy = true; reason = null; resetWatch(); // stop remaining scheduled checks TaskExecutor.getInstance().shutDown(); // try to start publisher if (RabbitMQPublisher.getInstance() == null) { healthy = false; } // try to start consumer if (!ConsumeManager.startDataAndCommandProcessing()) { healthy = false; // shut down publisher RabbitMQPublisher.shutDown(); } // schedule micro service check scheduleCheck(); } }