easy-batch job listeners

easy-batch giving the listeners we provide a log monitoring a system state point, while
providing a barrier based on different types of monitoring

Job listener

job related

  • Method signature to be implemented
 
public interface JobListener {
    void beforeJobStart(JobParameters parameters);
    void afterJobEnd(JobReport report);
}
  • Reference picture

 

 

 

  • Registration method
Job job = new JobBuilder()
    . jobListener ( new MyJobListener)
    .build();
  • Some scenes
Setting up and requesting Liyuan (before / after job)
Lock (unlock) working directory (start / stop job)
Archive log Files AT at The End of the Job log file archiving (job end)
execution perform complete sending mail
。。。。

Record reader/writer listeners

  • Method signature
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);
}
  • Reference picture

 

 

 

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

Processing pipeline listener

  • Method signature
public interface PipelineListener {
    Record beforeRecordProcessing(final Record record);
    void afterRecordProcessing(final Record inputRecord, final Record outputRecord);
    void onRecordProcessingException(final Record record, final Throwable throwable);
}
  • Reference picture

 

 

  • registered
Job job = new JobBuilder()
    .pipelineListener(new MyPipelineListener())
    .build();
  • Some scenes
Calculate the processing time of each record
Customize the processing of each record in pre / post
。。。。

Batch listener

  • Method signature
public interface BatchListener {
    void beforeBatchReading();
    void afterBatchProcessing(final Batch batch);
    void afterBatchWriting(final Batch batch);
    void onBatchWritingException(final Batch batch, Throwable throwable);
}
  • Reference picture

 

 

  • registered
Job job = new JobBuilder()
    .batchListener(new MyBatchListener())
    .build();
  • Some scenes
The DEFINE Transaction boundaries boundary definition affairs
Customize each batch pre / post process stage
。。。。

References

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

Guess you like

Origin www.cnblogs.com/rongfengliang/p/12732804.html