To understand the field-grouping of Apache Storm, I thought of creating a single spout which will emit few fixed lines to a bolt. The bolt (let's call it emitter) in turn will emit words along with a tag (in Storm's parlance a Field) say "WORD". In the next layer, I wanted to set up three bolts (call them counters) - expecting each of the counters to receive same words whenever the spout produce them. But I have never expected that the same words would be given to all of the counters- which is surprisingly what is happening with below topology.
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("reader",new ReaderSpout());
builder.setBolt("emitter", new EmitterBolt()).shuffleGrouping("reader");
builder.setBolt("counter1", new CounterBolt(),1)
.fieldsGrouping("emitter", new Fields("WORD"));
builder.setBolt("counter2", new CounterBolt(),1)
.fieldsGrouping("emitter", new Fields("WORD"));
builder.setBolt("counter3", new CounterBolt(),1)
.fieldsGrouping("emitter", new Fields("WORD"));
Any help will be much appreciated.
My primary objective to understand the usefulness of 'fieldsGrouping', and soft objective is to have a two counter-bolts one receiving words staring with vowel and other bolts receiving words starting with consonants.
question from:
https://stackoverflow.com/questions/65944382/field-groping-in-apache-storm-looking-for-motivational-examples 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…