ChunkListener
1 Spring Batch ChunkListener 개요
- Spring Batch에서 ChunkListener는 청크 처리 과정의 주요 이벤트를 감지하고 반응할 수 있게 해주는 인터페이스입니다.
- 청크(Chunk)란 Spring Batch에서 데이터를 처리할 때 사용하는 작은 데이터 덩어리를 의미합니다.
- ChunkListener를 사용하면 청크 처리의 시작, 성공, 실패 등의 이벤트를 모니터링하고 필요한 작업을 수행할 수 있습니다.
2 ChunkListener 인터페이스
- ChunkListener 인터페이스는 다음과 같은 메 서드를 제공합니다:
public interface ChunkListener extends StepListener {
void beforeChunk(ChunkContext context);
void afterChunk(ChunkContext context);
void afterChunkError(ChunkContext context);
}
beforeChunk(ChunkContext context)
: 청크 처리 시작 전에 호출됩니다.afterChunk(ChunkContext context)
: 청크 처리가 성공적으로 완료된 후 호출됩니다.afterChunkError(ChunkContext context)
: 청크 처리 중 에러가 발생했을 때 호출됩니다.