使用 HikariCP 的属性配置 Spring 云连接器的 PoolConfig 和 ConnectionConfig

Configuring Spring Cloud Connectors' PoolConfig and ConnectionConfig using HikariCP's properties

我正在尝试使用 HikariCP 的 配置 Spring Cloud Connector 的 PoolConfigConnectionConfig属性。

这是我的 Sring Cloud Connector 数据源配置:

@Configuration
@Profile({Profiles.CLOUD, Profiles.DEV})
public class DataSourceConfiguration extends AbstractCloudConfig {

    @Bean
    @Qualifier("application_database")
    @Primary
    public DataSource applicationDatasource() {
        PoolConfig poolConfig = new PoolConfig(5, 11, 3000);//Notice 11 for maxPoolSize
        ConnectionConfig connConfig = new ConnectionConfig("poolName=dummy;characterEncoding=UTF-8");
        DataSourceConfig dbConfig = new DataSourceConfig(poolConfig, connConfig);
        return connectionFactory().dataSource("application_database", dbConfig);
    }
}

这是 HikariCP 报告:

16:56:55.916 [main] INFO  o.s.c.s.r.PooledDataSourceCreator - Found HikariCP on the classpath. Using it for DataSource connection pooling.
16:56:56.315 [main] DEBUG com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - allowPoolSuspension.............false
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - autoCommit......................true
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - catalog.........................null
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionInitSql...............null
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTestQuery............."SELECT 1"
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - connectionTimeout...............30000
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSource......................null
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceClassName.............null
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceJNDI..................null
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - dataSourceProperties............{password=<masked>}
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - driverClassName................."org.postgresql.Driver"
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckProperties...........{}
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - healthCheckRegistry.............null
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - idleTimeout.....................600000
16:56:56.318 [main] DEBUG com.zaxxer.hikari.HikariConfig - initializationFailFast..........true
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - isolateInternalQueries..........false
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbc4ConnectionTest.............false
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl........................."jdbc:postgresql://localhost:5432/bignibou_application?user=postgres&password=postgres"
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - leakDetectionThreshold..........0
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - maxLifetime.....................1800000
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - maximumPoolSize.................10 //Notice the default value is unchanged...
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricRegistry..................null
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - metricsTrackerFactory...........null
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - minimumIdle.....................10
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - password........................<masked>
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - poolName........................"HikariPool-1"
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - readOnly........................false
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - registerMbeans..................false
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - scheduledExecutorService........null
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - threadFactory...................null
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - transactionIsolation............null
16:56:56.319 [main] DEBUG com.zaxxer.hikari.HikariConfig - username........................null
16:56:56.320 [main] DEBUG com.zaxxer.hikari.HikariConfig - validationTimeout...............5000
16:56:56.320 [main] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Started.
16:56:56.387 [main] INFO  com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Driver does not support get/set network timeout for connections. (La fonction org.postgresql.jdbc.PgConnection.getNetworkTimeout() n'est pas encore implémentée.)
16:56:56.411 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@57a3cabf
16:56:56.505 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=0)
16:56:56.513 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@3a34aac7
16:56:56.541 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@74fe29ac
16:56:56.551 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@3772d6e0
16:56:56.557 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@7ecd1483
16:56:56.563 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@6130eb0f
16:56:56.568 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@64860dcc
16:56:56.573 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@45e2026a
16:56:56.581 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@539d6f59
16:56:56.586 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@35939eb6
16:56:56.586 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After adding stats (total=10, active=1, idle=9, waiting=0)

可以注意到 HikariCP 没有考虑 PoolConfig 中指定的 11maxPoolSize:Hikari 的 maximumPoolSize 保持在:10。 .. 有人可以帮忙吗?

我看到你已经 filed a GitHub issue 了。您似乎发现了连接器上的错误。我会在问题中进一步评论。