bolt BaseBasicBolt BaseRichBolt

 

2017年04月16日 16:21:28

阅读数:412

baseBasicBolt 自带ack 机制

下面是BasicBoltExecutor的一段源码,如果你写的bolt跑出FailedException 异常,basicBolt会调用fail,如果处理成功,会调用ack方法

public void execute(Tuple input) {
    _collector.setContext(input);
    try {
        _bolt.execute(input, _collector);
        _collector.getOutputter().ack(input);
    } catch(FailedException e) {
        if(e instanceof ReportedFailedException) {
            _collector.reportError(e);
        }
        _collector.getOutputter().fail(input);
    }
}

猜你喜欢

转载自blog.csdn.net/wangshuminjava/article/details/81113363