Search in sources :

Example 1 with DB2Pool

use of io.vertx.mutiny.db2client.DB2Pool in project quarkus by quarkusio.

the class ReactiveDB2DataSourcesHealthCheck method call.

@Override
public HealthCheckResponse call() {
    HealthCheckResponseBuilder builder = HealthCheckResponse.named("Reactive DB2 connections health check");
    builder.up();
    for (Entry<String, DB2Pool> db2PoolEntry : db2Pools.entrySet()) {
        String dataSourceName = db2PoolEntry.getKey();
        DB2Pool db2Pool = db2PoolEntry.getValue();
        try {
            db2Pool.query("SELECT 1 FROM SYSIBM.SYSDUMMY1").execute().await().atMost(Duration.ofSeconds(10));
            builder.withData(dataSourceName, "up");
        } catch (Exception exception) {
            builder.down();
            builder.withData(dataSourceName, "down - connection failed: " + exception.getMessage());
        }
    }
    return builder.build();
}
Also used : HealthCheckResponseBuilder(org.eclipse.microprofile.health.HealthCheckResponseBuilder) DB2Pool(io.vertx.mutiny.db2client.DB2Pool)

Example 2 with DB2Pool

use of io.vertx.mutiny.db2client.DB2Pool in project quarkus by quarkusio.

the class ReactiveDB2DataSourcesHealthCheck method init.

@PostConstruct
protected void init() {
    ArcContainer container = Arc.container();
    DataSourcesHealthSupport excluded = container.instance(DataSourcesHealthSupport.class).get();
    Set<String> excludedNames = excluded.getExcludedNames();
    for (InstanceHandle<DB2Pool> handle : container.select(DB2Pool.class, Any.Literal.INSTANCE).handles()) {
        String db2PoolName = getDB2PoolName(handle.getBean());
        if (!excludedNames.contains(db2PoolName)) {
            db2Pools.put(db2PoolName, handle.get());
        }
    }
}
Also used : ArcContainer(io.quarkus.arc.ArcContainer) DataSourcesHealthSupport(io.quarkus.datasource.runtime.DataSourcesHealthSupport) DB2Pool(io.vertx.mutiny.db2client.DB2Pool) PostConstruct(javax.annotation.PostConstruct)

Aggregations

DB2Pool (io.vertx.mutiny.db2client.DB2Pool)2 ArcContainer (io.quarkus.arc.ArcContainer)1 DataSourcesHealthSupport (io.quarkus.datasource.runtime.DataSourcesHealthSupport)1 PostConstruct (javax.annotation.PostConstruct)1 HealthCheckResponseBuilder (org.eclipse.microprofile.health.HealthCheckResponseBuilder)1