3

这是我的数据库健康检查:

@Readiness
@ApplicationScoped
@Slf4j
public class DatabaseConnectionHealthCheck implements HealthCheck {

    @Inject
    PgPool pgPool;

    @Override
    public HealthCheckResponse call() {
        final HealthCheckResponseBuilder responseBuilder = HealthCheckResponse.named("Database connection health check");

        try {
            pgPool.getConnection().await().indefinitely();
            log.info("Database Connection Health Check - Success");
            responseBuilder.up();

        } catch( CompletionException e ){
            log.info("Database Connection Health Check - Failure - Cause {}", e.getMessage());
            responseBuilder
                    .down()
                    .withData(
                            "Cause",
                            e.getMessage()
                    );
        }
        return responseBuilder.build();
    }
}

问题是做 .await().indefinitely() 而我不想要它(io.vertx.core.VertxException:线程被阻塞)

如何以反应/订阅方式 responseBuiler.up() ?

谢谢

4

0 回答 0