Apache storm 在Storm Trident中发射到多个流
如何从风暴三叉戟中的同一个闪电发射到多个流 我有一个螺栓,它进行一些计算,根据计算结果,我想将一些值传递给一个流,将一些其他值传递给另一个流 在暴风雨中(不是三叉戟),我们可以通过以下方式实现:Apache storm 在Storm Trident中发射到多个流,apache-storm,trident,Apache Storm,Trident,如何从风暴三叉戟中的同一个闪电发射到多个流 我有一个螺栓,它进行一些计算,根据计算结果,我想将一些值传递给一个流,将一些其他值传递给另一个流 在暴风雨中(不是三叉戟),我们可以通过以下方式实现: // main stream Stream stream = topology.each(...) // stream 01 Stream stream1 = stream.each(...) // stream 02 Stream stream2 = stream.each(...) 将流拆分为
// main stream
Stream stream = topology.each(...)
// stream 01
Stream stream1 = stream.each(...)
// stream 02
Stream stream2 = stream.each(...)
将流拆分为多个流:
@Override
public void declareOutputFields(final OutputFieldsDeclarer outputFieldsDeclarer) {
outputFieldsDeclarer.declareStream("type1-stream", new Fields("type1"));
outputFieldsDeclarer.declareStream("type2-stream", new Fields("type2"));
outputFieldsDeclarer.declareStream("error-stream", new Fields("error"));
}
然后根据调查结果进行排放,如:
collector.emit("type1-stream", new Values("type 1 data"));
collector.emit("type2-stream", new Values("type 2 data"));
collector.emit("error-stream", new Values("error data"));
然后通过收听预期的流来完成剩余的工作:
builder.setBolt("errorBolt", errorBolt).shuffleGrouping("errorBoltStream", "error-stream");
builder.setBolt("type1Bolt", type1Bolt).shuffleGrouping("type1BoltStream", "type1-stream");
那么,如何使用Storm Trident实现相同的行为呢
一个选项是为同一个流调用“each”,并运行相同的螺栓,仅根据我要向该流发送的内容进行发送,或者另一个选项是emit key和value pair,并根据key(如type1、type2、error等)过滤流,然后再次创建多个流。但在我看来,没有一个是好的设计。实现这一目标的最佳方法是什么?好吧,你不能这么做。
要分割流,您需要执行以下操作:
// main stream
Stream stream = topology.each(...)
// stream 01
Stream stream1 = stream.each(...)
// stream 02
Stream stream2 = stream.each(...)
好了,你不能这么做。
要分割流,您需要执行以下操作:
// main stream
Stream stream = topology.each(...)
// stream 01
Stream stream1 = stream.each(...)
// stream 02
Stream stream2 = stream.each(...)
我也有同样的问题。这有一个问题:我也有同样的问题。这其中有一个问题: