ahojte,

vo webovej aplikacii mam problem s pripojenim na DB (PostgreSQL) a na
noSQL REDIS, pomocou connectoru JEDIS, pouzivam tomcat 7.0.29.

aplikacia po par minutach pouzivania "zastane". predpokladam, ze je
problem v apache commons connection pool-e.

pouzivam:

- pripojenie na REDIS pomocou JEDIS connector (jedis-2.1.0.jar)
- pripojenie na 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

po debugovani som zistil, ze sa pouziva pravdepodobne jeden connection
pool a v triede:

org.apache.commons.pool.impl.GenericObjectPool, v funkcii

public T borrowObject() throws Exception {
...
if (latch.getPair() == null && !latch.mayCreate()) {
if(maxWait <= 0) {
latch.wait();

pretoze latch.getPair() = null, maxWait is -1 a latch.mayCreate() ==
false, takze latch.wait() sa vykona, a aplikacia "zastane".

je mozne vobec pouzivat jeden connection pool pre pripojenie na
PostgreSQL DB aj na pripojenie na REDIS ? nemam skusenosti s
pripojenim na viacere "zdroje" dat v jednej aplikacii.

nastavenie connection pool-u je default.

pre informaciu, pouzivanie JEDIS-u:

1.
RedisTemplate<String, String> redisTemplate = (RedisTemplate<String,
String>) BeanUtil.getBean("redisTemplate");
return redisTemplate.boundZSetOps(set).incrementScore(key , value);
2.
RedisTemplate<String, String> redisTemplate = (RedisTemplate<String,
String>) BeanUtil.getBean("redisTemplate");
Set<Tuple> mostViewed = redisTemplate.execute(new RedisCallback<Set<Tuple>>() {
@Override
public Set<Tuple> doInRedis(RedisConnection con)
throws DataAccessException {
Set<Tuple> zRangeByScoreWithScore =
con.zRangeByScoreWithScores(ARTICLE_VIEWS_SET.getB ytes(), 1, 10);
return zRangeByScoreWithScore;
}
});

---

jedisConnectionFactory definicia:

<bean id="jedisConnectionFactory"
class="org.springframework.data.redis.connection.j
edis.JedisConnectionFactory">
<property name="hostName" value="${redis.host}"/>
<property name="port" value="${redis.port}"/>
<property name="timeout" value="2000"/>
</bean>

dakujem za akekolvek rady

Ivan

Odpovedet emailem