Spring Batch 입문: 3시간 만에 끝내는 대용량 처리의 기초
understanding-chunk-oriented-processing
✅ 1. 스프링 배치의 두가지 방법
- 청크 지향 처리(Chunk Oriented Processing)
- 태스크릿 지향 처리(Tasklet Oriented Processing)
✅ 2. 청크 지향 처리
- 데이터 100만개를 처리할때 1000개짜리 덩어리로 툭툭 잘라서 처리함
- 대용량 처리가 필요할 때 해당 방식을 사용한다.
- 매월 1일, 멤버십 포인트 지급
- 배송 상태 일괄 변경
- 구형 시스템 데이터 이관
- 실패하더라도 현재 청크 단위부터 시작하면 된다.
✅ 3. 청크 지향 처리 인터페이스
public interface ItemReader<T> {
T read() throws Exception,
UnexpectedInputException,
ParseException,
NonTransientResourceException;
}
public interface ItemProcessor<I, O> {
O process(I item) throws Exception;
}
public interface ItemWriter<T> {
void write(Chunk<? extends T> chunk) throws Exception;
}
👩💼
스프링 배치에서는 청크 지향 처리를 쉽게 구현하기 위한 인터페이스 3종을 지원합니다.
지금은 너무 어렵게 생각하지말고, 데이터를 읽고 - 가공하여 - 쓰는 루틴을 가진다고 생각하고 넘어갑시다.