public static StormTopology buildTopology(Map<String, SpoutDetails> spoutMap, Map<String, BoltDetails> boltMap) { TopologyBuilder builder = new TopologyBuilder(); for (Entry<String, SpoutDetails> entry : spoutMap.entrySet()) { String spoutId = entry.getKey(); SpoutDetails spec = entry.getValue(); SpoutDeclarer spoutDeclarer = builder.setSpout(spoutId, spec.getSpout(), spec.getParallelism()); spoutDeclarer.addConfigurations(spec.getConf()); } for (Entry<String, BoltDetails> entry : boltMap.entrySet()) { String spoutId = entry.getKey(); BoltDetails spec = entry.getValue(); BoltDeclarer boltDeclarer = null; if (spec.bolt instanceof IRichBolt) { boltDeclarer = builder.setBolt(spoutId, (IRichBolt) spec.getBolt(), spec.getParallelism()); } else { boltDeclarer = builder.setBolt(spoutId, (IBasicBolt) spec.getBolt(), spec.getParallelism()); } boltDeclarer.addConfigurations(spec.getConf()); addInputs(boltDeclarer, spec.getInputs()); } return builder.createTopology(); }