0

I'm using redis 2.8.19 and jedis 2.6.0

pool = new JedisPool( new JedisPoolConfig(), "ip", 6379, 0 );
        System.out.println( "test2" );
        Jedis jedis = pool.getResource();
        jedis.psubscribe( new KeyExpiredListener(), "__key*__:*" );
        pool.returnResource( jedis );
        System.out.println( "test3" );

output:

test2

The app seems to hang when i try to subscribe to a channel. So the question I pose is why is my application hanging because of this.

2 Answers2

2

psubscribe is a blocking operation. You need to execute the psubscribe call on a seperate thread.

betaboy00
  • 651
  • 6
  • 5
0

Fixed this by setting notify-keyspace-events to Ex in the redis.conf

and listening to "__keyevent@0__:*"

jedis.psubscribe( new KeyExpiredListener(), "__keyevent@0__:*" );