正在获取backtype.storm.已生成.拓扑无效异常:null,如果我注解setBolt调用,它将运行

jaql4c8m  于 2022-12-09  发布在  Apache
关注(0)|答案(1)|浏览(175)

如果注解builder.setBolt,那么它运行正确。请告诉我哪里出错了

TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("words", new TestWordSpout(), 3);
    //Calling setBolt
    builder.setBolt("exc", new ExclaimBolt(),3)
    .allGrouping("words");

    Config conf = new Config();
    conf.setDebug(false);
    //conf.setNumWorkers(2);

    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("test", conf, builder.createTopology());
wqnecbli

wqnecbli1#

没有在Spout中声明输出字段。声明后工作正常。
代码示例(在u bolt类中):

@Override

public void declareOutputFields(OutputFieldsDeclarer declarer) {

    declarer.declare(new Fields("msg"));//based on u project

}

相关问题