1、原理:
storm的lib下的jar,
external\storm-kafka\storm-kafka-0.9.2-incubating.jar 此jar中的sqout已经写好
2、/********** KafkaTopoMain :运行,在本地生成文件****************/
public class KafkaTopoMain {
public static void main(String[] args) {
BrokerHosts hosts = new ZkHosts("weekend05:2181,weekend06:2181,weekend07:2181");
String topic = "order_name";
String zkRoot="/kafka-storm";
String spoutId = "KafkaSpoutId";
SpoutConfig spoutConfig = new SpoutConfig(hosts, topic, zkRoot, spoutId);
spoutConfig.forceFromStart = true;//设置从头开始
spoutConfig.scheme = new SchemeAsMultiScheme(new MessageScheme());//反序列化,将byte专为String
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(spoutId, new KafkaSpout(spoutConfig));
builder.setBolt("word_split", new WordSplitBolt(), 4).shuffleGrouping(spoutId); //文件分割
builder.setBolt("write", new WordWrit