I am doing poc(Redis + springboot + jpa) ,when I am setting Redis Property setEnableTransactionSupport(true ) then exception of Transaction does not support in clustermode , when I am setting setEnableTransactionSupport(false) during getting redisTemplate then exception of resource pool is coming.
@Note: This problem is happing when I setup Redis and spring boot are on different machine. I have 6 nodes , 3 are master and 3 are slaves.
But When I setup whole on single machine(spring + Redis ), then it's working fine.
below are my dependencies:
[<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>]
[<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
<type>jar</type>]
I have tried what was suggested in below link: Jedis, Cannot get jedis connection: cannot get resource from pool below is my configuration for Redis Connection factory:
## Redis Properties(application.properties)
spring.redis.cluster.nodes=127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002
RedisClusterConfigProp.java
@Component
@ConfigurationProperties(value = "spring.redis.cluster")
public class RedisClusterConfigProp {
List<String> nodes;
/**
* @return the nodes
*/
public List<String> getNodes() {
return nodes;
}
/**
* @param nodes
* the nodes to set
*/
public void setNodes(List<String> nodes) {
this.nodes = nodes;
}
}
RedisClusterConfigration.java
@Configuration
public class RedisClusterConfigration {
@Autowired
public RedisClusterConfigProp clusterConfigProp;
@Bean
public RedisConnectionFactory redisConnectionFactory() {
JedisConnectionFactory jedisConnFac = new JedisConnectionFactory(
new RedisClusterConfiguration(clusterConfigProp.getNodes()), new JedisPoolConfig());
jedisConnFac.getPoolConfig().setMaxIdle(40);
jedisConnFac.getPoolConfig().setMinIdle(20);
return jedisConnFac;
}
@Bean
public RedisTemplate redisTemplate() {
RedisTemplate template = new RedisTemplate();
template.setConnectionFactory(redisConnectionFactory());
template.setEnableTransactionSupport(false);
return template;
}