Skip to content

Instantly share code, notes, and snippets.

@hlassiege
Last active August 29, 2015 14:04
Show Gist options
  • Save hlassiege/27bd5a5e5bc8bb1da94c to your computer and use it in GitHub Desktop.
Save hlassiege/27bd5a5e5bc8bb1da94c to your computer and use it in GitHub Desktop.
JestHealth
{
"status": "UP",
"jestHealth":
{
"status": "UP",
"lastQuerySuccess": true
},
"rabbit":
{
"status": "UP",
"version": "3.3.4"
}
}
package com.hopwork.hopsearch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
@ComponentScan(value = {"com.hopwork", "com.lateralthoughts"})
public class HopSearchApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(HopSearchApplication.class, args);
}
}
@Component
public class JestHealth implements HealthIndicator {
@Autowired
private JestClient client;
@Override
public org.springframework.boot.actuate.health.Health health() {
Health health = new Health.Builder().build();
try {
JestResult execute = client.execute(health);
return org.springframework.boot.actuate.health.Health.up().withDetail("lastQuerySuccess", execute.isSucceeded()).build();
} catch (Exception e) {
return org.springframework.boot.actuate.health.Health.down(e).build();
}
}
}
<!-- Spring boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment