Loading pom.xml +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <version>2.1.0.RELEASE</version> <relativePath/> </parent> Loading @@ -28,8 +28,8 @@ <redmic.rest-lib.version>0.6.0</redmic.rest-lib.version> <!-- OTHERS --> <kafka.version>1.1.0</kafka.version> <confluent.version>4.1.2</confluent.version> <kafka.version>2.0.0</kafka.version> <confluent.version>5.0.0</confluent.version> <powermock-tests-utils.version>1.6.6</powermock-tests-utils.version> <commons-io.version>1.3.2</commons-io.version> Loading src/main/java/es/redmic/commandslib/config/GenerateJsonSchemaScanBean.java +2 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,8 @@ public class GenerateJsonSchemaScanBean implements ApplicationContextAware { public Map<String, Object> getProperties() { if (properties.isEmpty()) { String serverPath = env.getProperty("server.servlet.context-path") + env.getProperty("server.servlet.path"); String serverPath = env.getProperty("server.servlet.context-path") + env.getProperty("spring.mvc.servlet.path"); for (Iterator it = ((AbstractEnvironment) env).getPropertySources().iterator(); it.hasNext();) { PropertySource propertySource = (PropertySource) it.next(); if (propertySource instanceof MapPropertySource) { Loading src/main/java/es/redmic/commandslib/health/KafkaHealthCheck.java 0 → 100644 +37 −0 Original line number Diff line number Diff line package es.redmic.commandslib.health; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Component; @Component public class KafkaHealthCheck implements HealthIndicator { private KafkaTemplate<String, String> kafka; @Autowired public KafkaHealthCheck(KafkaTemplate<String, String> kafka) { this.kafka = kafka; } /** * Return an indication of health. * * @return the health for */ @Override public Health health() { try { kafka.send("kafka-health-indicator", "❥").get(100, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { return Health.down(e).build(); } return Health.up().build(); } } No newline at end of file Loading
pom.xml +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <version>2.1.0.RELEASE</version> <relativePath/> </parent> Loading @@ -28,8 +28,8 @@ <redmic.rest-lib.version>0.6.0</redmic.rest-lib.version> <!-- OTHERS --> <kafka.version>1.1.0</kafka.version> <confluent.version>4.1.2</confluent.version> <kafka.version>2.0.0</kafka.version> <confluent.version>5.0.0</confluent.version> <powermock-tests-utils.version>1.6.6</powermock-tests-utils.version> <commons-io.version>1.3.2</commons-io.version> Loading
src/main/java/es/redmic/commandslib/config/GenerateJsonSchemaScanBean.java +2 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,8 @@ public class GenerateJsonSchemaScanBean implements ApplicationContextAware { public Map<String, Object> getProperties() { if (properties.isEmpty()) { String serverPath = env.getProperty("server.servlet.context-path") + env.getProperty("server.servlet.path"); String serverPath = env.getProperty("server.servlet.context-path") + env.getProperty("spring.mvc.servlet.path"); for (Iterator it = ((AbstractEnvironment) env).getPropertySources().iterator(); it.hasNext();) { PropertySource propertySource = (PropertySource) it.next(); if (propertySource instanceof MapPropertySource) { Loading
src/main/java/es/redmic/commandslib/health/KafkaHealthCheck.java 0 → 100644 +37 −0 Original line number Diff line number Diff line package es.redmic.commandslib.health; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Component; @Component public class KafkaHealthCheck implements HealthIndicator { private KafkaTemplate<String, String> kafka; @Autowired public KafkaHealthCheck(KafkaTemplate<String, String> kafka) { this.kafka = kafka; } /** * Return an indication of health. * * @return the health for */ @Override public Health health() { try { kafka.send("kafka-health-indicator", "❥").get(100, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { return Health.down(e).build(); } return Health.up().build(); } } No newline at end of file