강의

멘토링

로드맵

인프런 커뮤니티 질문&답변

Junyi Song님의 프로필 이미지
Junyi Song

작성한 질문수

스프링 배치

ItemStream

ItemStream.update 관련

작성

·

290

0

9:46초경 ItemStream 프로세스 관련
 
- ItemStream.update() 메서드가 Chunk size만큼 반복된다고 나와 있는데
- TaskletStep의 doExecute() 메서드에서는 반복문 바깥에 stream.update() 메서드가 호출되어서 1번만 호출되는 것 같습니다
 
	@Override
	protected void doExecute(StepExecution stepExecution) throws Exception {
		stepExecution.getExecutionContext().put(TASKLET_TYPE_KEY, tasklet.getClass().getName());
		stepExecution.getExecutionContext().put(STEP_TYPE_KEY, this.getClass().getName());

		stream.update(stepExecution.getExecutionContext());
		getJobRepository().updateExecutionContext(stepExecution);

		// Shared semaphore per step execution, so other step executions can run
		// in parallel without needing the lock
		final Semaphore semaphore = createSemaphore();

퀴즈

Spring Batch 청크 처리에서 '청크'의 주된 목적은 무엇일까요?

개별 태스크 실행 단위를 정의합니다.

작업 매개변수 및 실행 컨텍스트를 관리합니다.

배치 처리를 위해 여러 항목을 묶어 트랜잭션 단위로 처리합니다.

개별 항목에 대한 예외만 처리합니다.

답변 1

0

정수원님의 프로필 이미지
정수원
지식공유자

네 

강의를 보시면 ItemReader 와 ItemWriter 가 chunkSize 만큼의 데이터 처리를 한 후 ItemStream.update() 가 실행된다고 설명하고 있습니다.

즉 ItemStream.update() 가 chunkSize 만큼 반복된다는 것이 아니라 chunkSize 단위로 실행된다고 보시면 됩니다.

예를 들어 chunkSize 가 10 이라고 한다면 ItemReader 가 10개의 데이터를 읽은 후 ItemStream.update() 가 발생하고 ItemWriter 가 10 개의 데이터가 담은 list 를 커밋한 후 ItemStream.update() 가 실행된다는 의미입니다.

 

Junyi Song님의 프로필 이미지
Junyi Song

작성한 질문수

질문하기