有没有办法将变量从 Bolt 传递到 Apache Storm 中的 Spout?

Is there a way to pass a variable from a Bolt to a Spout in Apache Storm?

在风暴中,信息流(元组)是从 Spout 到 Bolt。 为了防止信息过载,一开始我在 spout 过滤了大部分数据,但在处理数据之后,我想根据数据中的模式添加更多通过 spout 的信息。 换句话说,我想根据到目前为止螺栓处理的数据,在 运行 时间动态更改从 Spout 传递的信息。

没有。但是您可以将过滤逻辑从 spout 移出到一个新的第一个 bolt 中。 spout 只是获取所有数据并将其转发到新的过滤器螺栓。对于螺栓,图表中可能有循环,即,您可以将信息反馈给过滤器螺栓。例如这样的事情:

builder.addSpout("spout",...);
builder.addBolt("filter",...)
  .localOrShuffleGrouping("spout") // regular forward connection
  .allGrouping("someLaterBolt"); // cyclic feedback connection 
// add more bolts here
builder.addBolt("someLaterBolt",...).someConnectionPattern("somePreviousBolt")