@Override protected void doHealthCheck(Health.Builder builder) throws Exception { String product = getProduct(); builder.up().withDetail("database", product); String query = detectQuery(product); if (StringUtils.hasText(query)) { try { builder.withDetail("hello", this.jdbcTemplate.queryForObject(query, Object.class)); } catch (Exception ex) { builder.down(ex); } } }
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { log.debug("Initializing JavaMail health indicator"); try { javaMailSender .getSession() .getTransport() .connect( javaMailSender.getHost(), javaMailSender.getPort(), javaMailSender.getUsername(), javaMailSender.getPassword()); builder.up(); } catch (MessagingException e) { log.debug("Cannot connect to e-mail server. Error: {}", e.getMessage()); builder.down(e); } }