• easy-batch job listeners


    easy-batch 的listeners给与我们提供了一个系统状态的一个日志监控点,同时
    基于不同的类型提供了不通的监控

    Job listener

    job 关联的

    • 需要实现的方法签名
     
    public interface JobListener {
        void beforeJobStart(JobParameters parameters);
        void afterJobEnd(JobReport report);
    }
    • 参考图

    • 注册方法
    Job job = new JobBuilder()
        .jobListener(new MyJobListener())
        .build();
    • 一些场景
    设置以及请求梨园(before/after job)
    锁(解锁)工作目录(start/stop job)
    Archive log files at the end of Job 日志文件归档(job 结束)
    execution 执行完备发送邮件
    。。。。

    Record reader/writer listeners

    • 方法签名
    public interface RecordReaderListener {
        void beforeRecordReading();
        void afterRecordReading(Record record);
        void onRecordReadingException(final Throwable throwable);
    }
    public interface RecordWriterListener {
        void beforeRecordWriting(Batch batch);
        void afterRecordWriting(Batch batch);
        void onRecordWritingException(Batch batch, final Throwable throwable);
    }
    • 参考图

    • 注册
    Job job = new JobBuilder()
        .readerListener(new MyReaderListener())
        .writerListener(new MyWriterListener())
        .build();

    Processing pipeline listener

    • 方法签名
    public interface PipelineListener {
        Record beforeRecordProcessing(final Record record);
        void afterRecordProcessing(final Record inputRecord, final Record outputRecord);
        void onRecordProcessingException(final Record record, final Throwable throwable);
    }
    • 参考图

    • 注册
    Job job = new JobBuilder()
        .pipelineListener(new MyPipelineListener())
        .build();
    • 一些场景
    计算每条record 的processing 时间
    自定义每条record在pre/post的 processing 
    。。。。

    Batch listener

    • 方法签名
    public interface BatchListener {
        void beforeBatchReading();
        void afterBatchProcessing(final Batch batch);
        void afterBatchWriting(final Batch batch);
        void onBatchWritingException(final Batch batch, Throwable throwable);
    }
    • 参考图

    • 注册
    Job job = new JobBuilder()
        .batchListener(new MyBatchListener())
        .build();
    • 一些场景
    Define transaction boundaries 定义事务的边界
    自定义每个batch pre/post process 阶段
    。。。。

    参考资料

    https://github.com/j-easy/easy-batch/wiki/listeners

  • 相关阅读:
    linux tar 压缩解压缩
    JS获取图片上传地址
    ipython notebook
    docker build lnmp(未完成。。。)
    centos6.7 install chrome
    centos6.6 install
    centos 安装mysqldb 记录
    centos emacs安装
    第三周-第08章节-Python3.5-文件修改详解
    第三周-第06章节-Python3.5-文件读与写详解
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12732804.html
Copyright © 2020-2023  润新知