title: Handling KeyEventListener on Redis shutdown
body: <p>I have the written following subscriber on Redis which internally instantiate the listener:</p>
  
  <pre><code>public class RedisSubscriber extends Thread{
  
     String REDISHOST = "localhost";
     int REDISPORT = 6379;
     private static RedisSubscriber singleton = null;
     private Jedis sub;
     private KeyExpiredListener expireListener;
  
     public static synchronized RedisSubscriber getSingleton(){
        if(singleton==null){
            singleton = new RedisSubscriber();
        }
        return singleton;
     }
  
     private RedisSubscriber(){
         sub = new Jedis(REDISHOST, REDISPORT,0);
         expireListener = new KeyExpiredListener();
     }
  
     public void run() {
      //blocking call
  
      LOGGER.info("Inside Run - subscribing");
      try{
          sub.psubscribe(expireListener, "__key*__:*");
      }
      catch(JedisConnectionException ex){
          ex.printStackTrace();
      }
    }
  }
  
  public class KeyExpiredListener extends JedisPubSub {
  
     @Override
     public void onPSubscribe(String pattern, int subscribedChannels) {
      System.out.println("onPSubscribe " + pattern + " " + 
      subscribedChannels);
      }
  
     @Override
     public void onPMessage(String pattern, String channel, String 
     message)     
     {
      System.out.println("onPMessage pattern " + pattern + " " + channel  
      + " " + message);
      }
      }
  }
  </code></pre>
  
  <p>Using following at the start of a server to start the RedisSubscriber-
      new Thread(RedisSubscriber.getSingleton()).start();</p>
  
  <p>Now if Redis goes down, this thread will be killed . How do I make sure my subscriber connects again when Redis is up.</p>
  
  <p>Thanks,
  Arpit.</p>