강의

멘토링

커뮤니티

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

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

작성한 질문수

스프링 배치

ItemStream

ItemStream.update 관련

작성

·

289

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();

답변 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

작성한 질문수

질문하기