Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 커스텀 로그인
- forNmae()
- paraller
- .getClass()
- Express
- exiting abnormally
- vue.js
- 자료구조
- $emit()
- VUE
- rabbitmq 에러
- 오라클 병렬처리
- 공식문서
- AWS
- 리액트
- react
- 리덕스 공식문서
- REDIS
- 자바
- 도커빌드
- 애그리거트
- 오라클
- 네임드 뷰
- ACCESS_REFUSED
- 컴포넌트 주도
- Java Reflextion API
- EBS
- quert
- redux
- 리덕스
Archives
- Today
- Total
개발정리
스프링 배치 - Hello World 본문
- Job
- 배치 처리 과정을 하나의 단위로 만들어 표현한 객체
- 하나의 Job 객체는 여러 Step 인스턴스를 포함하는 컨테이너
- JobRepository
- 배치 처리 정보를 담고 있는 객체
- Job이 실행되었으면 배치 처리에 대한 모든 메타 데이터가 담겨있다.
- JobLauncher
- 배치를 실행시키는 인터페이스
- 클라이언트의 요청을 받아 Job을 실행
- Job,파라미터를 받아 실행하며 JobExecution을 반환한다.
- Step
- Job 내부에 구성되어 실제 배치 작업 수행을 정의하고 제어한다. Job을 처리하는 단위
- chunk 또는 tasklet이 포함되어 있다
Hello World 예제
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
@Configuration
public class HelloJobConfig {
@Bean
public Job helloJob(JobRepository jobRepository, Step helloStep1) {
return new JobBuilder("helloJob", jobRepository)
.start(helloStep1)
.build();
}
@Bean
public Step helloStep1(JobRepository jobRepository, Tasklet helloStep1Tasklet1, PlatformTransactionManager platformTransactionManager) {
return new StepBuilder("helloStep1Tasklet1", jobRepository)
.tasklet(helloStep1Tasklet1, platformTransactionManager)
.build();
}
@Bean
public Tasklet helloStep1Tasklet1() {
return ((contribution, chunkContext) -> {
//log.info("Hello World");
System.out.println("Hello World");
return RepeatStatus.FINISHED;
});
}
}
'스프링 > 스프링 프레임워크' 카테고리의 다른 글
스프링-유효성검사 (0) | 2024.05.12 |
---|---|
스프링 - 트랜잭션 전파속성 문서 읽기 (1) | 2024.04.12 |
스프링 트랜잭션 모델의 장점 (0) | 2024.02.15 |
스프링-트랜잭션 management (0) | 2024.02.15 |
스프링 STOMP - 메세지 흐름 (0) | 2024.02.15 |