假设我有依赖于(调用)Spring Boot服务B的Spring Boot服务A。
A -> B
弹簧启动执行器可以告诉我A是否启动。
https:// A / health
我想知道的是B是否通过呼叫A来启动。
https:// A / integratedhealth
我的问题是:Spring Boot执行器中是否存在检查子服务运行状况的标准方法?(或者我是否只需要构建定制的执行器服务?)
Spring Boot提供了许多开箱即用的健康指标。但是,您可以通过实现HealthIndicator
界面(ReactiveHealthIndicator
用于响应式应用程序)来添加自己的自定义健康指标:
@Component
public class ServiceBHealthIndicator implements HealthIndicator {
private final String message_key = "Service B";
@Override
public Health health() {
if (!isRunningServiceB()) {
return Health.down().withDetail(message_key, "Not Available").build();
}
return Health.up().withDetail(message_key, "Available").build();
}
private Boolean isRunningServiceB() {
Boolean isRunning = true;
// Your logic here
return isRunning;
}
}
如果将其与以前的其他健康指标结合使用,则可以通过以下方式获得健康端点响应:
{
"status":"DOWN",
"details":{
"serviceB":{
"status":"UP",
"details":{
"Service B":"Available"
}
},
"serviceC":{
"status":"DOWN",
"details":{
"Service C":"Not Available"
}
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句