Jedis onPMessage is not subscribing messages after sometime

时间:2019-04-23 15:08:04

标签: java redis jedis

I have used JedisPubSub to implement jedis subscriber for getting expiry keys and their messages. After certain time, onPMessage(pattern, channel, message) stops to subscribe the messages but onPSubscribe(pattern, channel) is being called. I am using dedicated jedispool connection for subscriber and publisher. Can anyone help me out in knowing, why it has stopped subscribing the messages?

Notification Listener:

public class KeyExpiredListener extends JedisPubSub {

@Override
public void onPSubscribe(String pattern, int subscribedChannels) {
    LOGGER.info("onPSubscribe " + pattern + " " + subscribedChannels + "\n");
}

@Override
public void onPMessage(String pattern, String channel, String message) {
    LOGGER.info("onPMessage pattern " + pattern + " " + channel + " " + message);
}

}

Subscriber:

public class Subscriber {

public static void main(String[] args) {
    JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost");

    Jedis jedis = pool.getResource();
    jedis.psubscribe(new KeyExpiredListener(), "__key*__:*");

}

}

Expected : Every time onPMessage() should trigger whenever message comes.

Actual: It stops triggering after certain count of messages.

0 个答案:

没有答案