Item processing

2025. 10. 9. 00:48·Book/Spring Batch docs

❐ 1. Chaining itemProcessor


  • ItemProcessor로 부가적인 로직을 짤 수 있음.
  • 근데 ItemProcessor를 체이닝을 걸어서 쓰고 싶다면?
@Configuration
class BatchConfig {

    @Bean
    fun ioSampleJob(jobRepository: JobRepository, step1: Step): Job =
        JobBuilder("ioSampleJob", jobRepository)
            .start(step1)
            .build()

    @Bean
    fun step1(
        jobRepository: JobRepository,
        transactionManager: PlatformTransactionManager
    ): Step =
        StepBuilder("step1", jobRepository)
            .chunk<Any, Any>(2, transactionManager)
            .reader(fooReader())
            .processor(compositeProcessor())
            .writer(foobarWriter())
            .build()

    @Bean
    fun compositeProcessor(): CompositeItemProcessor<Any, Any> =
        CompositeItemProcessor<Any, Any>().apply {
            setDelegates(listOf(FooProcessor(), BarProcessor()))
        }

    // 아래 메서드/클래스들은 실제 구현에 맞게 정의되어 있어야 합니다.
    fun fooReader() = /* ItemReader<Any> */ TODO()
    fun foobarWriter() = /* ItemWriter<Any> */ TODO()

    class FooProcessor : ItemProcessor<Any, Any> {
        override fun process(item: Any): Any? = /* transform */ item
    }

    class BarProcessor : ItemProcessor<Any, Any> {
        override fun process(item: Any): Any? = /* transform */ item
    }
}

 

 

나머지는 읽어보면 될듯.

'Book > Spring Batch docs' 카테고리의 다른 글

Retry  (0) 2025.10.10
Scaling and Parallel Processing  (0) 2025.10.10
ItemReaders and ItemWriters  (0) 2025.10.07
Configuring a Step  (0) 2025.10.06
Configuring and Running a Job  (0) 2025.07.17
'Book/Spring Batch docs' 카테고리의 다른 글
  • Retry
  • Scaling and Parallel Processing
  • ItemReaders and ItemWriters
  • Configuring a Step
gilbert9172
gilbert9172
gilbert9172 님의 블로그 입니다.
  • gilbert9172
    バックエンド
    gilbert9172
  • 전체
    오늘
    어제
    • All Categories (207)
      • 우테코 7기 (21)
        • 1주차 (8)
        • 2주차 (5)
        • 3주차 (6)
      • Langauge (6)
        • Java (3)
        • Kotlin (3)
      • Back-End (13)
        • SpringBoot (1)
        • Trouble Shooting (0)
        • Setup & Configuration (1)
        • SQL (3)
        • Redis (8)
      • Architecture (6)
        • Multi Module (1)
        • DDD (5)
      • CS (30)
        • Data Structure (6)
        • Operating System (0)
        • Network (12)
        • Database (10)
        • Design Pattern (2)
      • Algorithm (78)
        • 내용 정리 (18)
        • 문제풀이 (60)
      • DevOps (6)
        • AWS (5)
        • Git (1)
      • Front-End (1)
        • Trouble Shooting (1)
      • Project (6)
        • 페이스콕 (6)
      • Book (39)
        • 친절한 SQL 튜닝 (9)
        • 데이터 중심 애플리케이션 설계 (14)
        • 이벤트 기반 마이크로서비스 구축 (6)
        • Spring Batch docs (10)
        • Quartz docs (0)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    부분단조성
    Two-Pointer
    sliding-window
    greedy
    binarysearch
    Back-Tracking
    오블완
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.2
gilbert9172
Item processing
상단으로

티스토리툴바