문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
springframework:batch [2019/12/03 14:10] kwon37xi |
springframework:batch [2023/12/08 13:43] kwon37xi [Java Config Spring Bean 설정시 리턴 타입을 인터페이스가 아닌 구현 클래스로 지정할 것.] |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Spring Framework Batch ====== | ====== Spring Framework Batch ====== | ||
* [[springframework: | * [[springframework: | ||
- | * [[http:// | ||
- | * [[https:// | ||
- | * [[http:// | ||
- | * [[https:// | ||
- | * Spring Batch 2.2 JavaConfig | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * Spring Batch Transaction | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[http:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | * [[http:// | ||
- | |||
===== @EnableBatchProcessing ===== | ===== @EnableBatchProcessing ===== | ||
줄 70: | 줄 37: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | * 테이블 생성시 명백하게 대문자로 테이블명을 생성해줘야한다. | ||
+ | * 만약 [[database: | ||
+ | * see [[database: | ||
===== Migration ===== | ===== Migration ===== | ||
줄 77: | 줄 47: | ||
===== Transaction 설정 ===== | ===== Transaction 설정 ===== | ||
+ | ==== Connection Pool 설정 ==== | ||
+ | * batch job 이 job 단위로 단독 프로세스로 실행되는 경우 | ||
+ | * batch job 은 실제로 Parallel 로 실행되는게 아니면 DB 커넥션이 1~2개 정도 밖에 필요하지 않다. | ||
+ | * parallel, async 실행에 대비해서 maximum connection 갯수는 충분한 숫자로 하되, | ||
+ | * minimum 갯수를 5개 혹은 그 이하로 지정해야 Batch job 이 실행 될 때마다 커넥션을 과도하게 맺느라 들어가는 실행시간 지연 문제를 해소하고, | ||
+ | |||
==== 트랜잭션 매니저를 지정하지 않으면 ==== | ==== 트랜잭션 매니저를 지정하지 않으면 ==== | ||
TransactionManager를 지정하지 않으면 다음과 같은 오류가 발생한다. | TransactionManager를 지정하지 않으면 다음과 같은 오류가 발생한다. | ||
줄 115: | 줄 91: | ||
* 외부에서 그 데이터를 사용할 수 있게 하고자 했다면, | * 외부에서 그 데이터를 사용할 수 있게 하고자 했다면, | ||
* 절대로 Step 에 트랜잭션 매니저를 지정하지 말고, '' | * 절대로 Step 에 트랜잭션 매니저를 지정하지 말고, '' | ||
+ | * '' | ||
* 안그러면 CHUNK size 만큼의 처리가 모두 끝날때까지 DB lock 이 잡혀있어서 외부에서 이벤트를 받아서 처리하는 측에서 lock 획득에 실패해서 오류가 발생하게 된다. | * 안그러면 CHUNK size 만큼의 처리가 모두 끝날때까지 DB lock 이 잡혀있어서 외부에서 이벤트를 받아서 처리하는 측에서 lock 획득에 실패해서 오류가 발생하게 된다. | ||
+ | * 이게 아니더라도, | ||
===== JobInstanceAlreadyCompleteException: | ===== JobInstanceAlreadyCompleteException: | ||
* Job은 Job + Job Parameter 로 Job Key 가 결정되는데 동일한 Job Key 일 경우 실행이 안된다. | * Job은 Job + Job Parameter 로 Job Key 가 결정되는데 동일한 Job Key 일 경우 실행이 안된다. | ||
줄 131: | 줄 108: | ||
===== RunIdIncrementer 사용시 기존 파라미터가 현재 파라미터 지정한 것을 덮어씀 | ===== RunIdIncrementer 사용시 기존 파라미터가 현재 파라미터 지정한 것을 덮어씀 | ||
- | * '' | + | * '' |
* 이유는 '' | * 이유는 '' | ||
- | * 따라서 '' | + | * 따라서 '' |
+ | * [[https:// | ||
* [[https:// | * [[https:// | ||
줄 162: | 줄 140: | ||
> o.s.b.c.l.AbstractListenerFactoryBean | > o.s.b.c.l.AbstractListenerFactoryBean | ||
+ | > org.springframework.batch.item.ItemReader는 인터페이스입니다. 구현 클래스는 어노테이션 기반 listener 구성에 대해 실행되지 않습니다. @Bean 메소드에서 @StepScope를 사용하는 경우 listner 어노테이션을 사용할 수 있도록 구현 클래스를 리턴해야합니다. | ||
+ | |||
+ | |||
줄 178: | 줄 159: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * Spring Batch 2.2 JavaConfig | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * Spring Batch Transaction | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// |