简体   繁体   中英

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

I am trying to configure Spring Cloud Connector's PoolConfig and ConnectionConfig using HikariCP's properties.

Here is my Sring Cloud Connector datasource configuration:

@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);
    }
}

Here is the HikariCP report:

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)

One can notice that maxPoolSize of 11 specified in PoolConfig is not taken into account by HikariCP: Hikari's maximumPoolSize remains at: 10 ... Can someone please help?

I see you've filed a GitHub issue for this. It looks like you've uncovered a bug on Connectors. I'll comment further in the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM