
springboot拦截所有healthindicator健康检查方法
为避免健康检查失败导致kubernetes服务重启,开发者需要拦截所有healthindicator调用并记录失败组件。由于healthindicator的实现方式,基于执行的切点无法拦截所有调用。
解决方法是使用基于@annotation的切点:
@around("@annotation(org.springframework.boot.actuate.health.healthindicator)")
public object healthindicatoradvice(proceedingjoinpoint pjp) throws throwable {
// 在此处记录失败的healthindicator实现
object result = pjp.proceed();
// 在此处进一步处理result
return result;
}登录后复制
此方法可拦截所有标注了@healthindicator注解的healthindicator实现的health()方法。
以上就是springboot如何拦截所有healthindicator的健康检查?的详细内容,更多请关注代码网其它相关文章!
发表评论