병렬 단계가 있는 Spring 배치 작업

https://grokonez.com/spring-framework/spring-batch/spring-batch-job-parallel-steps

병렬 단계가 있는 Spring 배치 작업

배치 작업을 확장하기 위한 병렬 단계는 애플리케이션의 비즈니스 논리를 기반으로 하는 하나의 솔루션입니다. 로직 비즈니스를 별개의 책임으로 분할하고 각 단계를 병렬 흐름으로 실행할 수 있습니다. 튜토리얼은 Spring Batch로 병렬 단계를 구성하는 방법을 안내합니다.

관련 기사:
  • Spring Batch Partition for Scaling & Parallel Processing
  • How to start with Spring Batch using Spring Boot – Java Config


  • I. 스프링 배치 병렬 단계 튜토리얼을 위한 기술



    – 자바 1.8
    – 메이븐 3.3.9
    – Spring 도구 세트 – 버전 3.8.1.RELEASE
    – 스프링 부트
  • MySQL 데이터베이스

    II. 개요


    1. 프로젝트 구조



    2. 해야 할 단계


  • Spring Boot 프로젝트 생성
  • 종속성 추가
  • 일괄 작업 데이터 소스 구성
  • 단순 Tasklet 단계 생성
  • 작업 시작 만들기
  • 배치 작업 활성화
  • XML 구성으로 Spring Batch 작업 정의
  • 실행 및 결과 확인

  • III. 관행



    1. 스프링 부트 프로젝트 생성



    Spring Tool Suite를 열고 메인 메뉴에서 File->New->Spring Starter Project를 선택하고 프로젝트 정보를 입력합니다. 그런 다음 마침을 누르면 스프링 부트 프로젝트가 생성됩니다.

    2. 종속성 추가



    spring-boot-starter-batch, spring-boot-starter-web, mysql-connector-java 추가
    <?xml version="1.0" encoding="UTF-8"?>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>  
        
          <dependency>
               <groupId>mysql</groupId>
               <artifactId>mysql-connector-java</artifactId>
               <scope>runtime</scope>
           </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>                              
    </dependencies>

    3. 배치 작업 데이터 소스 구성



    application.properties 열기, 배치 작업 저장소에 대한 스프링 데이터 소스 구성
    
    spring.datasource.url=jdbc:mysql://localhost:3306/testdb
    spring.datasource.username=root
    spring.datasource.password=12345
    spring.batch.job.enabled=false
    

    https://grokonez.com/spring-framework/spring-batch/spring-batch-job-parallel-steps

    병렬 단계가 있는 Spring 배치 작업

    좋은 웹페이지 즐겨찾기