5

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));
    }
Alex
  • 8,245
  • 8
  • 46
  • 55
Ganesh Pandey
  • 5,216
  • 1
  • 33
  • 39

1 Answers1

6

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

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117