An Apache Storm bolt receive multiple input tuples from different spout/bolt

女生的网名这么多〃 提交于 2019-12-07 08:42:43

问题


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.


回答1:


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.




回答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



来源:https://stackoverflow.com/questions/30410661/an-apache-storm-bolt-receive-multiple-input-tuples-from-different-spout-bolt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!