How spring cloud defines validation interval under

2019-08-18 06:19发布

I'm working on application that get the DS from PCF (Pivotal Cloud FoundrY) User provided services. It's working properly but I want to understand how the validation interval is defined.

As Spring and PCF are managing my connection pool. I'd like to understand how that works.

public DataSource getProfileDS() {    
     PoolConfig poolConfig = new PoolConfig(5, 10, 30000);
     DataSourceConfig dsConfig = new DataSourceConfig(poolConfig, null);
     return connectionFactory().dataSource("profileDS", dsConfig);
}

Also, is there any way to set up the validation interval by my own like we are used to do under the tomcat?

1条回答
霸刀☆藐视天下
2楼-- · 2019-08-18 06:38

How spring cloud defines validation interval under the Pivotal Cloud Foundry?

Spring Cloud Config will define a validation query that is appropriate for your relational database.

Examples:

As to the validation interval, it does not look like that's being configured. Instead, the DBCP-like pools use testOnBorrow, and Hikari is configured to use connectionTestQuery. When testing before obtaining a connection from the pool, setting the validation interval is unnecessary.

Also, is there any way to set up the validation interval by my own like we are used to do under the tomcat?

Not if you're going to use Spring Cloud Connectors, but you don't have to use Spring Cloud Connectors. There's a couple of other ways you can do this.

Hope that helps!

查看更多
登录 后发表回答