문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
springframework:batch [2018/07/25 17:07] kwon37xi [DefaultBatchConfigurer] |
springframework:batch [2018/11/21 17:33] kwon37xi [RunIdIncrementer 사용시 기존 파라미터가 현재 파라미터 지정한 것을 덮어씀] |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Spring Framework Batch ====== | ====== Spring Framework Batch ====== | ||
+ | * [[springframework: | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
* Spring Batch 2.2 JavaConfig | * Spring Batch 2.2 JavaConfig | ||
* [[https:// | * [[https:// | ||
줄 25: | 줄 28: | ||
* [[https:// | * [[https:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
===== @EnableBatchProcessing ===== | ===== @EnableBatchProcessing ===== | ||
* [[https:// | * [[https:// | ||
줄 52: | 줄 58: | ||
</ | </ | ||
* '' | * '' | ||
+ | * SpringBoot 에서 '' | ||
===== JobRepository ===== | ===== JobRepository ===== | ||
* '' | * '' | ||
줄 101: | 줄 107: | ||
</ | </ | ||
+ | ===== JobInstanceAlreadyCompleteException: | ||
+ | * Job은 Job + Job Parameter 로 Job Key 가 결정되는데 동일한 Job Key 일 경우 실행이 안된다. | ||
+ | * 따라서 Job Parameter를 다는 값으로 주거나 [[https:// | ||
+ | * [[https:// | ||
+ | * SpringBoot Batch 는 '' | ||
+ | <code java> | ||
+ | jobBuilderFactory.get(" | ||
+ | .start(step()) | ||
+ | . ..... | ||
+ | .incrementer(new RunIdIncrementer()) | ||
+ | .build(); | ||
+ | </ | ||
+ | |||
+ | ===== RunIdIncrementer 사용시 기존 파라미터가 현재 파라미터 지정한 것을 덮어씀 | ||
+ | * '' | ||
+ | * 이유는 '' | ||
+ | * 따라서 '' | ||
+ | * [[https:// | ||
+ | |||
+ | <code java> | ||
+ | /** | ||
+ | * 파라미터를 복사하지 않는 RunIdIncrementer | ||
+ | */ | ||
+ | public class ParamCleanRunIdIncrementer implements JobParametersIncrementer { | ||
+ | private static String RUN_ID_KEY = " | ||
+ | private String key = RUN_ID_KEY; | ||
+ | |||
+ | public void setKey(String key) { this.key = key; } | ||
+ | |||
+ | @Override | ||
+ | public JobParameters getNext(JobParameters parameters) { | ||
+ | JobParameters params = (parameters == null) ? new JobParameters() : parameters; | ||
+ | long id = params.getLong(key, | ||
+ | return new JobParametersBuilder().addLong(key, | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== 참고 ===== | ||
+ | * [[https:// | ||
+ | * [[https:// |