package kr.xit.core.biz.batch.listener;

import org.springframework.batch.core.ChunkListener;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * <pre>
 * description :  Chunk 실행시 로그 출력
 *
 * packageName : kr.xit.core.biz.batch.listener
 * fileName    : CustomChunkListener
 * author      : limju
 * date        : 2023-05-16
 * ======================================================================
 * 변경일         변경자        변경 내용
 * ----------------------------------------------------------------------
 * 2023-05-16    limju       최초 생성
 *
 * </pre>
 */
@Slf4j
@Component
public class CustomChunkListener {

    @Bean
    public ChunkListener chunkListener() {
        return new ChunkListener() {
            @Override
            public void beforeChunk(ChunkContext context) {
                log.info("↓ Chunk start");
            }

            @Override
            public void afterChunk(ChunkContext context) {
                log.info("↑ Chunk end");
            }

            @Override
            public void afterChunkError(ChunkContext context) {
                // Do nothing
            }
        };
    }
}
