首页 > 其他 > 详细

easy-batch job listeners

时间:2020-04-19 19:40:00      阅读:49      评论:0      收藏:0      [点我收藏+]

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

easy-batch job listeners

原文:https://www.cnblogs.com/rongfengliang/p/12732804.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!