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?
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.
- Spring Boot exposes
VCAP_SERVICES
as properties like vcap.services.<name>.credentials.username
. You could use those to manually define a DataSource. See here.
- You can use the new java-cfenv library, which is intended to complement Spring Boot better.
Hope that helps!