Closed cgfrost closed 9 years ago
@cgfrost We've been getting a few requests lately to add more ability to customize the connections created by SCC.
Some connector types (e.g. relational, mongo, rabbitmq) support a Config
class that can be used to set parameters for the created connection. We can add a RedisConnectionFactoryConfig
with this (and maybe a few other parameters) and change RedisConnectionFactoryCreator
to honor that.
This change allows a map of connection properties to be provided to customize the created RedisConnectionFactory
bean.
With XML configuration, you can now do something like this:
<cloud:redis-connection-factory id="redis" service-name="my-redis">
<cloud:connection-properties>
<entry key="timeout" value="10"/>
</cloud:connection-properties>
</cloud:redis-connection-factory>
With Java config, you can now do something like this:
@Configuration
class RedisConfig extends AbstractCloudConfig {
@Bean
public RedisConnectionFactory redisConnectionFactory() {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("timeout", 10);
RedisConnectionFactoryConfig serviceConfig = new RedisConnectionFactoryConfig(properties);
return connectionFactory().redisConnectionFactory("my-redis", serviceConfig);
}
}
Sometimes it takes too long to connect to a Redis instance and the default time out gets hit. It should be possible to specify a different time out in the ServiceConnectorConfig object.
https://github.com/spring-cloud/spring-cloud-connectors/blob/master/spring-cloud-spring-service-connector/src/main/java/org/springframework/cloud/service/keyval/RedisConnectionFactoryCreator.java