简体   繁体   English

Apache Storm螺栓从不同的喷口/螺栓接收多个输入元组

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

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. 例如,Bolt C从Spout A接收输入元组,从Bolt B接收要处理的元组。 How should I implement it? 我该如何实施呢? I mean writing the Java code for Bolt C and also its topology. 我的意思是编写Bolt C的Java代码及其拓扑。

Tutorial answers your question. 教程回答了你的问题。

https://storm.apache.org/documentation/Tutorial.html https://storm.apache.org/documentation/Tutorial.html

Here is the code for your goal(C/P from tutorial): 以下是您的目标代码(教程中的C / P):

builder.setBolt("exclaim2", new ExclamationBolt(), 5)
            .shuffleGrouping("words")
            .shuffleGrouping("exclaim1");

exclaim2 will accept tuples from both words and exclaim1 , both using shuffle grouping. exclaim2将接受来自两个wordsexclaim1元组,两者都使用shuffle分组。

Yes Possible. 是的可能。 Only thing to take care is it should follow DAG structure. 唯一需要注意的是它应遵循DAG结构。 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 1.喷口读取数据并发送到螺栓C 2.相同的喷口读取数据并发送到螺栓B 3.螺栓B过滤一些数据并转发到螺栓C

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM