zoukankan      html  css  js  c++  java
  • Storm框架:如何实现crontab定时任务

    Storm除了能对消息流进行处理,还能实现crontab定时任务。
    只要在bolt中配置TOPOLOGY_TICK_TUPLE_FREQ_SECS项即可实现。

    @Override
    public Map<String, Object> getComponentConfiguration() {
        Config conf = new Config();
        conf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, 60); //每隔60s发送一次tick信号
    
        return conf;
    }
    
    @Override
    public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
        if (tuple.getSourceComponent().equals(Constants.SYSTEM_COMPONENT_ID) &&
                tuple.getSourceStreamId().equals(Constants.SYSTEM_TICK_STREAM_ID)) {
    
            LOGGER.debug("CronBolt Tick at {}", new Date());
            // 执行定时任务操作
        } else {
            return;
        }
    }
    
  • 相关阅读:
    RabbitMQ管理
    vc6.0
    SystemTap
    undefined reference to `__imp_socket'
    采集小板校时
    点播播放不出来
    抓包注意事项
    下载rfc
    CLion快捷键
    rtsp vlc请求实例
  • 原文地址:https://www.cnblogs.com/gouyg/p/java-storm-crontab.html
Copyright © 2011-2022 走看看