These are chat archives for spring-cloud/spring-cloud

30th
Dec 2016
Chris Phillipson
@fastnsilver
Dec 30 2016 15:09

@ryangardner and/or anyone else here who’s had prior trouble getting spring-cloud-aws + spring-data-redis+ jedis-backed redisconnectionfactory + redistemplate configured successfully to interact with an aws elasticache node or cluster?

i have the following config (https://github.com/fastnsilver/monbox/blob/master/src/main/java/com/fns/monbox/config/AwsConfig.java, lines 55-60 of which are probably not even required) and (https://github.com/fastnsilver/monbox/blob/master/src/main/java/com/fns/monbox/config/RedisConfig.java). i am largely relying on auto-config for the rest. what am i missing?

i am seeing the following exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AWSCloudCollectorTask': Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

note: i am able to ssh into the ec2 instance hosting the service and i can execute a redis-cli -h {elasticache-endpoint} to successfully connect.

here’s my pom (https://github.com/fastnsilver/monbox/blob/master/pom.xml) for dependency particulars.

Chris Phillipson
@fastnsilver
Dec 30 2016 16:22

alternate pom here (https://github.com/fastnsilver/monbox/blob/ingalls-update/pom.xml) that updates dependencies to ingalls-rc1. also results in same exception w/ elasticache redis.

i’ve tried to launch w/ e.g., java -jar monbox-x.x.x-SNAPSHOT-exec.jar -Dspring.redis.cluster.nodes={node1}.usw2.cache.amazonaws.com:6379,{node2}.rftl3a.0001.usw2.cache.amazonaws.com:6379in addition to spring.redis.host={node1}.usw2.cache.amazonaws.com

Chris Phillipson
@fastnsilver
Dec 30 2016 21:24
so i did a remote debug on the EC2 instance and what i found was that RedisProperties fails to accept the command-line arguments -Dspring.redis.host or application.yml properties and opting instead to set the value of the Redis host to localhost, which of course causes a connection failure. getting in the middle and setting the property during a pass thru RedisAutoConfiguration allowed the service to connect the Elasticache endpoint. so digging deeper I find that there are 2 factory beans on classpath KeyValueRepositoryFactoryBean and RedisRepositoryFactoryBean and the existence of these tells Spring Data that there are multiple repos and it goes into a so-called “strict mode”. Now I will try to figure out how to prune away the KeyValueRepositoryFactoryBean.
Chris Phillipson
@fastnsilver
Dec 30 2016 22:05
strangely, while application.yml and -Dspring.redis.host args are not respected, if i simply execute export SPRING_REDIS_HOST=… before executing java -jar … or mvn spring-boot:run … the service starts and connects.