Is it possible for a bolt receive multiple input tuples from different spout/bolt? For instance, Bolt C receive input tuples from Spout A and input tuples from Bolt B to be processed. How should I implement it? I mean writing the Java code for Bolt C and also its topology.
Asked
Active
Viewed 4,149 times
5
-
What do you mean? I'm new here, so I don't exactly know what you mean. – Toshihiko May 23 '15 at 12:16
-
You should see a tick on the left of the each answer, if you think one of the answers are true, then click that tick. It tells others that you accepted the answer as a solution to your problem. You can also upvote nice questions and answers, telling they are worth reading. – Seçkin Savaşçı May 23 '15 at 12:17
-
For example someone just upvoted your question. – Seçkin Savaşçı May 23 '15 at 12:19
2 Answers
9
Tutorial answers your question.
https://storm.apache.org/documentation/Tutorial.html
Here is the code for your goal(C/P from tutorial):
builder.setBolt("exclaim2", new ExclamationBolt(), 5)
.shuffleGrouping("words")
.shuffleGrouping("exclaim1");
exclaim2
will accept tuples from both words
and exclaim1
, both using shuffle grouping.

Seçkin Savaşçı
- 3,446
- 2
- 23
- 39
-
This was helpful. It would be nice to know if chaining can be done dynamically (via a loop) also. I have a variable number of bolts that would be generated via a loop and I want all of them to send their emitted Tuples to a single bolt. `for(int i=0;i<10;++i) {builder.setBolt("a",new someBolt(),5).shuffleGrouping("Bolt"+i);}`. Each iteration of the loop should chain one more Bolt. Is it possible in any way? – Nav Apr 20 '16 at 06:46
2
Yes Possible. Only thing to take care is it should follow DAG structure. In your case, below is the flow. 1. Spout reads the data and sends to bolt C 2. Same Spout reads the data and sends to bolt B 3. Bolt B filters some data and forwards to Bolt C

Hariprasad Taduru
- 181
- 10