public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    // ----------type1
    /*
    builder.setSpout("word", new MyTestWordSpout(), 1);
    builder.setSpout("test_signal", new SignalSpout(), 1);
    builder.setBolt("exclaim1", new ExclamationBolt(), 6).shuffleGrouping(
    		"word");
    //signals 为SignalSpout的streamId
    builder.setBolt("exclaim2", new ExclamationBolt(), 8)
    		.fieldsGrouping("exclaim1", new Fields("word"))
    		.allGrouping("test_signal", "signals");

    Config conf = new Config();
    conf.setDebug(true);
    conf.setNumWorkers(5);
    */

    // -----------type2
    Config conf = new Config();
    // topic
    conf.put("meta.topic", "test_hotel_count");
    conf.setDebug(true);

    MetaClientConfig mcc = new MetaClientConfig();
    ZKConfig zkConfig = new ZKConfig();
    zkConfig.zkConnect = "10.10.100.1:12181";
    mcc.setZkConfig(zkConfig);

    ConsumerConfig cc = new ConsumerConfig();
    cc.setGroup("test_gsj_000652");

    Scheme scheme = new StringScheme();
    // spout
    MetaSpout ms = new MetaSpout(mcc, cc, scheme);
    SignalSpout ss = new SignalSpout();

    // bolt
    ExclamationBolt1 bolt1 = new ExclamationBolt1();
    ExclamationBolt2 bolt2 = new ExclamationBolt2();

    // builder
    builder.setSpout("metaq_test", ms, 1);
    builder.setSpout("test_signal", ss, 1);
    builder.setBolt("bolt1", bolt1, 6).shuffleGrouping("metaq_test");
    // signals 为SignalSpout的streamId
    builder
        .setBolt("bolt2", bolt2, 1)
        .fieldsGrouping("bolt1", new Fields("cat"))
        .allGrouping("test_signal", "signals");

    if (args != null && args.length > 0) {
      // topology 的工作进程数,若worker数量>1,则在某些worker的bolt2中无法收到消息,但是在其他某个特定的worker中可接受到消息,正常处理;
      // 是否某个bolt只在某个worker中运行?有待考证
      conf.setNumWorkers(1);
      StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
    } else {
      LocalCluster cluster = new LocalCluster();
      cluster.submitTopology("test", conf, builder.createTopology());
      Utils.sleep(10000000);
      cluster.killTopology("test");
      cluster.shutdown();
    }
  }