Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the Redis 'redis.publish()' method do?

What does redis.publish(); method do in the following module.

redis.publish("WordCountTopology", exclamatedWord.toString() + "|" + Long.toString(count));

public void execute(Tuple tuple)
    {
      String word = tuple.getString(0);

      StringBuilder exclamatedWord = new StringBuilder();
      exclamatedWord.append(word).append("!!!");

      _collector.emit(tuple, new Values(exclamatedWord.toString()));

      long count = 30;
      redis.publish("WordCountTopology", exclamatedWord.toString() + "|" + Long.toString(count));
    }
like image 964
Ganesh Pandey Avatar asked Jan 26 '15 11:01

Ganesh Pandey


1 Answers

It publishes the string (ExclamatedWord + "|30") to a Redis channel called WordCountTopology - subscribers to that channel will get the message once redis.publish executes.

For more information about Redis' Pub/Sub see: http://redis.io/topics/pubsub

like image 159
Itamar Haber Avatar answered Oct 12 '22 19:10

Itamar Haber