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

posted on   荣锋亮  阅读(272)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-04-19 转载一篇阿里云Terraform 开发指南
2019-04-19 zabbix 4.2 支持 timescledb 了
2018-04-19 使用distillery 实现版本的动态升级&& 动态降级
2018-04-19 使用distillery 构建专业的 phoenix 项目软件包
2018-04-19 mix deps HEX_HTTP_CONCURRENCY=1 HEX_HTTP_TIMEOUT=120 timeout
2018-04-19 elixir jenkins 集成构建方式配置
2018-04-19 phoenix 使用activerecord模式框架ecto 访问数据库

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示