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.
Spout emits the data to one or more bolts. Bolt represents a node in the topology having the smallest processing logic and the output of a bolt can be emitted into another bolt as input. Storm keeps the topology always running, until you kill the topology.
Bolt Creationprepare − Provides the bolt with an environment to execute. The executors will run this method to initialize the spout.
OutputFieldsDeclarer: used to declare streams and their schemas.
close − This method is called when a spout is going to shutdown. declareOutputFields − Declares the output schema of the tuple. fail − Specifies that a specific tuple is not processed and not to be reprocessed.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With