I'm struggling with the concept of creating a Jedis client that listens endlessly as a subscriber to the pubsub Redis channel and processes messages when they enter.
My problem is that after some time of inactivity the server stops responding silently. I think this is due to the timeout that occurs on the Jedis client I signed up with.
Is this really so? If so, is there a way to configure this Jedis client for no timeout? (While other Jedispools are not affected by some kind of global timeout) Alternatively, is there another way (best practice) of what I'm trying to achieve?
This is my code (modified / removed for display):
executed when the web server starts:
new Thread(AkkaStarter2.getSingleton()).start();
AkkaStarter2.java
private Jedis sub;
private AkkaListener akkaListener;
public static AkkaStarter2 getSingleton(){
if(singleton==null){
singleton = new AkkaStarter2();
}
return singleton;
}
private AkkaStarter2(){
sub = new Jedis(REDISHOST, REDISPORT);
akkaListener = new AkkaListener();
}
public void run() {
sub.psubscribe(akkaListener, AKKAPREFIX + "*");
}
class AkkaListener extends JedisPubSub {
....
public void onPMessage(String pattern, String akkaChannel,String jsonSer) {
...
}
}
Thank.