new Thread(new Runnable() { @Override public void run() { Jedis subscriberJedis = new Jedis("localhost"); try { subscriberJedis.subscribe(new JedisPubSub() …..,"CC"); } catch (Exception e) { e.printStackTrace(); } } }).start();
So basically the subscription is done in a separate thread as it is a blocking operation.
A question I get about this is-Eventually, whenever the JVM running this subscriber thread is shut, would the socket used by the connection get closed automatically (given that it is a perpetually running thread and we are not calling jedis.disconnect() or jedis.quit() before the JVM is shut)?
Thank you
Neelesh
+odown mymaster localhost 6379
cacheClient.subscribe(sentinelListener, "+odown");
cacheClient.subscribe(sentinelListener, "+odownmymaster localhost 6379");
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/groups/opt_out.
If I understand correctly it is the same case with a single threaded jedis app and the jvm shuts down. It won't execute a quit or disconnect and redis will close the connection after the configured idle timeout.
Or maybe when the jvm shuts down it send a tcp rst and redis knows that it needs to close the connection.
Either way, redis will take care of it.
Jonathan