TIL

Job과 메타데이터 저장소

Spring Batch의 메타데이터 저장소

Spring Batch 핵심 도메인

JobInstance

JobParameters

JobExecution

BatchStatus

JobInstance 재실행 제한

재실행 검사 메커니즘

메타데이터 테이블 초기화 설정

spring:
  sql:
    init:
      mode: always
      schema-locations: classpath:org/springframework/batch/core/schema-drop-postgresql.sql

JobParametersIncrementer

public interface JobParametersIncrementer {  
   JobParameters getNext(@Nullable JobParameters parameters);  
}
@Bean
public Job brutalizedSystemJob() {
    return new JobBuilder("brutalizedSystemJob", jobRepository)
            .incrementer(new RunIdIncrementer())
            .start(brutalizedSystemStep())
            .build();
}

JobParameter의 identifying 속성

{'chaos':'{value=true, type=class java.lang.Boolean, identifying=true}',
 'run.id':'{value=2, type=class java.lang.Long, identifying=true}'}
./gradlew bootRun --args='--spring.batch.job.name=brutalizedSystemJob chaos=true,java.lang.Boolean verbose=true,java.lang.String,false'

restartable 설정

@Bean
public Job brutalizedSystemJob() {
    return new JobBuilder("brutalizedSystemJob", jobRepository)
            .start(brutalizedSystemStep())
            .preventRestart()
            .build();
}