Job 생성 import lombok.RequiredArgsConstructor; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.scope...
Job 생성 import lombok.RequiredArgsConstructor; import org.springframework.batch.core.*; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframe..
재실행에 포함시키기 - allowStartIfCompleted(true) @Bean public Step limitAllowStepStep1() { return stepBuilderFactory.get("limitAllowStepStep1") .tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.out.println("limitAllowStepStep1"); return RepeatStatus.FINISHED; } }) .allowStartIfComplete(true) // COMPLETED 되도 ..
해당 포스팅의 결론 여러개의 Tasklet을 선언할 경우 마지막에 선언된 Tasklet이 수행된다. @Bean public Step onlyTaskletStep2() { return stepBuilderFactory.get("onlyTaskletStep2") .tasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.out.println("실행되면 안되요"); return RepeatStatus.FINISHED; } }) .tasklet(new OnlyTasklet()) // 여러개 불가능, 마지막 ta..
incrementer() 사용 이유를 알아보자. Job 생성 package com.project.springbatch._20_incrementer; import lombok.RequiredArgsConstructor; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration..
preventRestart() 1) 선언하지 않는 경우 - true @Bean public Job preventRestartJob() { return this.jobBuilderFactory.get("preventRestartJob") /* step start */ .start(preventRestartStep1()) .next(preventRestartStep2()) .build(); } 2) 선언하는 경우 - false @Bean public Job preventRestartJob() { return this.jobBuilderFactory.get("preventRestartJob") /* step start */ .start(preventRestartStep1()) .next(preventResta..
Validator 생성 CustomJobParametersValidator.java import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersInvalidException; import org.springframework.batch.core.JobParametersValidator; public class CustomJobParametersValidator implements JobParametersValidator { @Override public void validate(JobParameters jobParameters) throws JobParametersInvalidEx..
Job 생성 import lombok.RequiredArgsConstructor; import org.springframework.batch.core.*; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.launch.support.RunIdIncrementer; import org.springframework.batch.core.scope.context.ChunkContext; import or..
Job 생성 이전에 배웠었던 기본 Job import lombok.RequiredArgsConstructor; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.b..
Listner 생성 및 설정 JobRepositoryListener.java import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.batch.core.*; import org.springframework.batch.core.repository.JobRepository; import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor @Slf4j public class JobRepositoryListener implements JobExecutionListener { private final Jo..
BATCH 테이블 Prefix 변경해보기 schema-postgresql.sql org.springframework.batch/spring-batch-core/4.3.5/b5ff5d227600df2ba087344160db2b8a38476cb3/spring-batch-core-4.3.5.jar!/org/springframework/batch/core/schema-postgresql.sql 위 파일의 쿼리를 가져와서, BATCH_ 부분을 SYSTEM_으로 변경해준다. -- Autogenerated: do not edit this file CREATE TABLE SYSTEM_JOB_INSTANCE ( JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY , VERSION BIGINT ..
ExecutionContext 개념 https://devfunny.tistory.com/485 [스프링 배치] 배치 잡의 세션 ExecutionContext 상황 스프링 배치가 진행중이다. 진행 도중에 오류가 발생했고, 실패한 시점부터 처리를 다시 시작해야한다. 이 경우에 스프링 배치는 실패한 시점을 어떻게 알아낼 수 있을까? 실패시마다, 사 devfunny.tistory.com 실습해보기 ExecutionContextConfiguration.java ExecutionContextTasklet1.java ExecutionContextTasklet2.java ExecutionContextTasklet3.java ExecutionContextTasklet4java ExecutionContextConfigur..