> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/v.-spring-boot-actuator/50.-endpoints/50.9-health-information/50.9.3-reactive-health-indicators.md).

# 50.9.3 响应式的健康指示器

对于响应式应用程序，例如那些使用Spring WebFlux的应用程序，`ReactiveHealthIndicator`提供了一个非阻塞契约来获得应用程序的健康状态。与传统的`HealthIndicator`类似，健康信息收集自`ApplicationContext`中定义的所有[`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java) bean。不检查响应式API的常规`HealthIndicator`bean包含在弹性调度器中并在其上执行。

要从响应式API提供自定义健康信息，你可以注册实现[`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java)接口的Spring bean。下面的代码显示了一个示例`ReactiveHealthIndicator`实现：

```
@Component
public class MyReactiveHealthIndicator implements ReactiveHealthIndicator {

    @Override
    public Mono<Health> health() {
        return doHealthCheck() //perform some specific health check that returns a Mono<Health>
            .onErrorResume(ex -> Mono.just(new Health.Builder().down(ex).build())));
    }

}
```

**注** 要自动处理错误，可以考虑从`AbstractReactiveHealthIndicator`扩展。
