Announcement Announcement Module
No announcement yet.
web application with PostgreSQL DB and JEDIS (REDIS) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • web application with PostgreSQL DB and JEDIS (REDIS)

    Hi, I used in my web application (Spring, JSP, Tomcat) TWO connections:

    - connection to REDIS by JEDIS connector (jedis-2.1.0.jar)
    - connection to PostgreSQL DB (JDBC driver: postgresql-9.1-901.jdbc4.jar).

    REDIS server version: 2.4 (windows version)
    JEDIS version: 2.1.0
    connection pool: apache commons pool version 1.6
    tomcat version: 7.0.29
    integration REDIS with spring: spring-data-redis-1.0.3.RELEASE.jar

    everythink is OK, but after a few minutes application freezes. I debug my application, and I think problem is in connection pool in class: org.apache.commons.pool.impl.GenericObjectPool, in function
    public T borrowObject() throws Exception {
    if (latch.getPair() == null && !latch.mayCreate()) {
    if(maxWait <= 0) {

    because, latch.getPair() = null, maxWait is -1 and latch.mayCreate() == false, so latch.wait is executed, and application freezes.

    I think problem is, there is only one connection pool for JDCB connection to PostgreSQL and for JEDIS.

    please, how can I define two independent connection pools, or there is another problem?

    thanks for you advice

    examples of usage o JEDIS from my application:
    RedisTemplate<String, String> redisTemplate = (RedisTemplate<String, String>) BeanUtil.getBean("redisTemplate");
    return redisTemplate.boundZSetOps(set).incrementScore(key , value);
    RedisTemplate<String, String> redisTemplate = (RedisTemplate<String, String>) BeanUtil.getBean("redisTemplate");
    Set<Tuple> mostViewed = redisTemplate.execute(new RedisCallback<Set<Tuple>>() {
    public Set<Tuple> doInRedis(RedisConnection con)
    throws DataAccessException {
    Set<Tuple> zRangeByScoreWithScore = con.zRangeByScoreWithScores(ARTICLE_VIEWS_SET.getB ytes(), 1, 10);
    return zRangeByScoreWithScore;


    jedisConnectionFactory definition:

    <bean id="jedisConnectionFactory" class=" edis.JedisConnectionFactory">
    <property name="hostName" value="${}"/>
    <property name="port" value="${redis.port}"/>
    <property name="timeout" value="2000"/>

    Last edited by termix; Mar 22nd, 2013, 06:06 PM.

  • #2
    I don't think your Postgres and Jedis connections are sharing a pool, as the JedisConnectionFactory creates a new pool instance. It seems you are using RedisTemplate in a fairly standard way, so connections should be getting returned to the pool, though you can set a breakpoint in JedisConnection.close() or JedisPool.returnResource() to verify. You may also want to check JedisPool.returnBrokenResource(), perhaps the connections are all getting invalidated somehow?

    If the pause is temporary and you do have a lot of concurrent active connections to Redis, you may need to adjust the poolConfig attribute of JedisConnectionFactory to increase your pool size, maxWait, etc.