Closed spring-projects-issues closed 4 years ago
John Blum commented
Users have asked how to configure the socketConnectTimeout
property (using the appropriate SDG FactoryBean
setter method, i.e. setSocketConnectTimeout(:int)
, with either the ClientCacheFactoryBean
when configuring the "DEFAULT" Pool
or using the PoolFactoryBean
when configuring a "named" Pool
) dynamically?
By way of example, if you users are using SDG's Annotation-based configuration model, then users could do the following:
@ClientCacheApplication
@EnablePools(pools = {
@EnablePool(name = "PoolOne"),
@EnablePool(name = "PoolTwo"),
@EnablePool(name = "PoolThree")
})
class GeodeConfiguration {
@Bean
ClientCacheConfigurer defaultPoolSocketConnectTimeoutConfigurer(
@Value("${some.external.property:5000}") int timeout) {
return (beanName, clientCacheFactoryBean) -> clientCacheFatoryBean.setSocketConnectTimeout(timeout);
}
@Bean
PoolConfigurer namedPoolSocketConnectTimeoutConfigurer(@Value("${some.external.property:5000}") int timeout) {
return (beanName, poolFactoryBean) -> {
// Only configure the 'socketConnectTimeout' for "PoolOne" and "PoolTwo"
// NOT for "PoolThree"
if (Arrays.asList("PoolOne", "PoolTwo").contains(beanName)) {
poolFactoryBean.setSocketConnectTimeout(timeout);
}
};
}
}
However, if the user is directly using the SDG API in Spring container Java-based configuration with the SDG FactoryBeans
, and specifically, the ClientCachFactoryBean
and (possibly) PoolFactoryBean
s, then the following would be equivalent to the above:
@Configuration
class GeodeConfiguration {
@Bean
ClientCacheFactoryBean gemfireCache(@Value("${some.external.proeprty:5000}") int timeout) {
ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean();
gemfireCache.setSocketConnectTimeout(timeout);
...
return gemfireCache;
}
@Bean("PoolOne")
PoolFactoryBean poolOne(@Value("${some.external.property:5000}") int timeout) {
PoolFactoryBean pool = new PoolFactoryBean();
pool.setSocketConnectTimeout(timeout);
...
return pool;
}
@Bean("PoolTwo")
PoolFactoryBean poolTwo(@Value("${some.external.property:5000}") int timeout) {
PoolFactoryBean pool = new PoolFactoryBean();
pool.setSocketConnectTimeout(timeout);
...
return pool;
}
@Bean("PoolThree")
PoolFactoryBean poolThree(@Value() {
PoolFactoryBean pool = new PoolFactoryBean();
...
return pool;
}
}
John Blum opened DATAGEODE-335 and commented
Currently, the
@ClientCacheApplication
annotation as well as the@EnablePool
annotation from SDG are missing a configuration attribute and associated property (e.g.spring.data.gemfire.pool.socket-connect-timeout
) forsocketConnectTimeout
, which is part of the GemFire/Geode API in theClientCacheFactory
class as well as thePoolFactory
interface.This property (and setter) have been appropriately added to the
ClientCacheFactoryBean
as well as thePoolFactoryBean
SDG classes.Therefore, the
socketConnectTimeout
configuration setting should be appropriately added to the@ClientCacheApplication
and@EnablePool
annotations as both an attribute and property in SDG, respectivelyAffects: 2.1.17 (Lovelace SR17), 2.2.7 (Moore SR7), 2.3 RC2 (Neumann)
Backported to: 2.2.8 (Moore SR8), 2.1.18 (Lovelace SR18)