spring - Spring Boot Actuator - 禁用默认调度间隔
问题描述
我正在为我的 Spring Boot 应用程序实现自定义 Actuator HealthIndicators。
它们看起来像:
public class MyClass implements HealthIndicator {
@Override
public Health health() {
LOGGER.info("Checking Service Health...");
try {
String url = this.getExternalServiceUrl().concat("/heartbeat");
JSONObject response = this.getResponse(url, null);
Boolean responseSuccess = response.getBoolean("success");
Boolean serviceAvailable = ...
if (responseSuccess && serviceAvailable) {
return Health.up().withDetail(...).build();
} else {
return Health.down().withDetail(...).build();
}
} catch (Exception e) {
return Health.down().withDetail(...).build();
}
}
}
本质上,我的应用程序依赖于其他外部 Web 服务,当我调用我的心跳页面时,我希望它能够 ping 这些服务的心跳,并相应地更改我的应用程序的 UP 或 DOWN 状态。
我的问题是,默认情况下,Actuator 似乎有 5 分钟左右的预定时间,它会自动调用/actuator/health
端点。我想禁用它。
我只想在代码中明确调用健康端点时调用它。
有谁知道如何禁用执行器默认调度?
我在用着spring-boot-actuator:2.1.3.RELEASE
解决方案
Spring Boot 永远不会自动调用自己的健康端点。如果它每 5 分钟被调用一次,那么它是在您部署了正在执行此操作的应用程序的环境中。
推荐阅读
- ejabberd - Ejabberd 身份验证
- python - 如何从列表中删除少于 N 个标记的字符串?
- javascript - ReactStrap 处理输入隐式提交
- excel - VBA,活动工作表问题
- dataframe - 在 Julia 中加入 DataFrame
- git - How to fetch gitlab repo using composer and cache
- python-3.x - 使用 **kwargs 创建一个字典-ValueError:字典更新序列元素 #0 的长度为 1;2 是必需的
- c - Android-NDK:在 Android API 27 中使用 shmget、shmctl、shmdt 时出现运行时错误
- javascript - Vuejs initialize a global dictionary and access it from other components
- ios - 检测音量按钮即使在音量最大时按下