Tasklet vs Step

목표 Spring batch의 Tasklet과 Step의 차이점을 이해한다. 차이점 Tasklet은 Step 안의 작업의 전략을 나타내는 함수형 인터페이스다. Job에는 여러개의 Step이 있고, Step은 Tasklet을 이용해 표현할 수 있다. 참고 자료 https://docs.spring.io/spring-batch/docs/current/api/org/springframework/batch/core/step/tasklet/Tasklet.html https://stackoverflow.com/questions/40041334/difference-between-step-tasklet-and-chunk-in-spring-batch

2024-09-15 · 1 min · 30 words

Spring Batch 시작하기

목표 Spring Batch의 구조를 이해한다. Spring Batch 사용법을 이해한다. Spring Batch 구조 스프링 배치는 Application, Batch Core, Batch Infrastructure 3가지 컴포넌트를 가진다. Application: 개발자가 작성하는 모든 배치 job과 사용자 정의 코드가 있다. Batch Core: 배치 작업을 시작하고 제어하는 데 필요한 핵심 런타임 클래스가 포함되어 있다. JobLauncher, Job, Step 구현체가 존재한다. Batch Infratstructure: 애플리케이션 개발자와 배치 코어에서 사용하는 클래스들이 포함되어 있다. ItemReader, ItemWriter RetryTemplate 하나의 Job에는 여러 개의 Step이 있고, Step에는 ItemReader, ItemProcessor, ItemWriter를 하나씩 가지고 있다....

2024-09-15 · 3 min · 452 words

JobParameters

목표 JobParameters가 무엇인지 이해한다. JobParameters 배치 작업에서 런타임 매개변수를 던져주기 위한 VO다. 이를 사용하기 위해서는 Job이나 Step의 late binding이 가능하도록 설정해야된다. late binding으로 동작하고자 하는 Step은 아래와 같이 step scope를 지정하면 된다. 이는 Job을 실제로 실행하기 전까지 인스턴스화 하지 않는다. 또한 Step을 실행할 때 마다가 각자 다른 인스턴스가 실행되어서 병렬 처리시에 충돌이 발생하지 않는다. @StepScope @Bean public FlatFileItemReader flatFileItemReader(@Value("#{jobParameters['input.file.name']}") String name) { return new FlatFileItemReaderBuilder<Foo>() .name("flatFileItemReader") .resource(new FileSystemResource(name)) ... } 참고 자료 https://docs....

2024-09-15 · 1 min · 76 words