Search code examples
apache-storm

How to use FieldGroupings in Storm


In bolt I have below records
bolt1 -> (id , dept , salary) Assume running task is 6

Next bolt has to receive the data based on the id. could anyone give me the sample code, how to use fieldGrouping.


Solution

  • TopologyBuilder builder = new TopologyBuilder();
    builder.addSpout("spout" new MySpout());
    builder.addBolt("bolt1", new Bolt1()).shuffleGrouping("spout"); // Bolt1 emits (id, dept, salary)
    builder.addBolt("bolt2", new Bolt2()).fieldsGrouping("bolt1", new Fields("id"));