Skip to content

simplydemo/spring-batch-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-batch-demo

Checkout

git clone https://github.com/chiwoo-samples/spring-batch-demo.git

# for intellij
# idea spring-batch-demo

Build

./mvnw clean package -DskipTests=true

Run

java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloFirstJob
java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloSecondJob
java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloSequentialJob
java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloConditionalJob -processorNo=2
java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloFirstJob,helloSecondJob,helloSequentialJob

Use Cases

Hello First

HelloFirstJob 는 "Hello World!" 문자열을 출력하는 가장 단순한 배치 프로세스 입니다.

java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloFirstJob

Hello Second

HelloSecondJob 는 reader -> processor -> writer 로 역할이 분리된 가장 기본적인 Tasklet 으로 chunk-size 단위로 배치 프로세스를 실행 합니다.

java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloSecondJob

Hello Listener

HelloListenerJobConfig 는 Job, StepExecution, Chunk 에 대해 각각 리스너를 추가 하고 배치 프로세서 실행시 각 리스너의 pre / post 프로세스를 통해 공통 작업을 지원할 수 있습니다.

java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloListenerJob

Hello Sequential

HelloSequentialJobConfig 는 step1 -> step2 -> step3 작업이 순차적으로 실행 합니다.

java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloSequentialJob

Hello Conditional

HelloConditionalJobConfig 는 step1 의 작업 처리 결과가 성공인 경우와 실패인 경우에 대해 각각 다른 유형으로 배치 프로세스를 실행 합니다.
입력 answer 값이 홀수 이면 step1 이 성공을, 짝수 이면 실패를 반환 합니다.

Case1) step1 의 처리 결과가 '성공'인 경우
  step1 -> step2 ->step3 
Case2) step1 의 처리 결과가 '실패'인 경우
  step1 -> step4      
# 성공 프로세스 실행 예시 
java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloConditionalJob -answer=1

# 실패 프로세스 실행 예시  
java -jar target/spring-batch-demo-0.0.1-SNAPSHOT.jar --job.names=helloConditionalJob -answer=2

Releases

No releases published

Packages

No packages published

Languages