easy-batch 的listeners给与我们提供了一个系统状态的一个日志监控点,同时
基于不同的类型提供了不通的监控
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 执行完备发送邮件
。。。。
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();
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
。。。。
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
原文:https://www.cnblogs.com/rongfengliang/p/12732804.html