Question

I have Redis installed on my machine and I am using a Jedis client within my Spring app to write some data onto Redis. For certain reasons, with each write, the number of connections to Redis keep piling up until I get a JedisConnectionFailureException.

My Spring Jedis Config file looks like this :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd">


<!-- Redis conection factory configurations -->
<bean id="redisConnectionFactory"   class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
                                    p:host-name="${redis.host}" 
                                    p:port="${redis.port}" 
                                    p:password="${redis.password}"
                                    p:use-pool="true" />

<!-- Redis String Serializer -->
<bean id="stringRedisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>

<!-- JDK Serialization Redis Serializer -->
<bean id="jdkSerializationRedisSerializer" class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>

<!-- Configuring the Redis Template -->
<bean id="redisTemplate"  class="org.springframework.data.redis.core.RedisTemplate"
                            p:connection-factory-ref="redisConnectionFactory" 
                            p:keySerializer-ref="stringRedisSerializer"
                            p:valueSerializer-ref="jdkSerializationRedisSerializer" />

Within my entire app, this is the only place where I'm creating connections.

In my spring-app, I'm using the connections as follows :

redisTemplate.opsForValue().set("key", "value");
Était-ce utile?

La solution

The issue is around wrong Spring Data Redis TX Sync algorithm - it has bugs.

It has been fixed and is available since Spring Data Redis 1.3 GA

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top