this question takes 3 seconds! What is Redis subscription channel?

21 views
Skip to first unread message

Joe Jung

unread,
Jul 1, 2015, 4:56:20 PM7/1/15
to redi...@googlegroups.com
Hey guys, really stumped here:

I created JedisSubscription class (extends JedisPubSub) and subscription instance, but I am not sure what the CHANNEL should be: is it 

1) IP and PORT address of my master?
2) specific status message that I would like to receive information about?
3) my master's name?

Thanks a bunch! 

final Jedis slave1 = pool.getResource(); // just a node of Redis instance  

        final JedisSubscription listener = new JedisSubscription();

        

        new Thread(new Runnable() {

            @Override

            public void run() {

                try {

                    log.info("Subscribing to \"mymaster\". This thread is blocked.");

                    slave1.subscribe(listener, "+odown");

                    log.info("Subscription ended.");

                } catch(Exception ex) {

                    log.error("Subscription failure: ", ex);

                }

            }

        }).start();


Greg Andrews

unread,
Jul 1, 2015, 7:18:19 PM7/1/15
to redi...@googlegroups.com
The channel name is the name of an object on the Redis server.  The documentation doesn't describe what format the channel name should be in, but I believe following the guidelines for ordinary key names is a good starting point.  (the documentation says pub/sub channels are not keys, though)

The description and examples at http://redis.io/topics/pubsub suggest useful channel names would be topics like "news.music.jazz" or "apache.log.errors" rather than server identifiers like "12.34.56.78:8080".  However, you can pick the name that makes sense to you.

  -Greg

--
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/d/optout.

Reply all
Reply to author
Forward
0 new messages