Merge pull request 'feature/cha' (#89) from feature/cha into dev
Reviewed-on: #89
This commit is contained in:
commit
d315066402
@ -0,0 +1,59 @@
|
||||
package com.interplug.qcast.config.batch;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
|
||||
import org.springframework.batch.support.DatabaseType;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
/**
|
||||
* Spring Batch Configuration for SQL Server without sequence support
|
||||
*/
|
||||
@Configuration
|
||||
@EnableBatchProcessing(modular = false)
|
||||
public class BatchConfiguration {
|
||||
|
||||
/**
|
||||
* Custom JobRepository that uses table-based ID generation instead of sequences
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
public JobRepository jobRepository(DataSource dataSource, PlatformTransactionManager transactionManager) throws Exception {
|
||||
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
|
||||
factory.setDataSource(dataSource);
|
||||
factory.setTransactionManager(transactionManager);
|
||||
|
||||
// 테이블 prefix 설정
|
||||
factory.setTablePrefix("BATCH_");
|
||||
|
||||
// 격리 레벨 설정
|
||||
factory.setIsolationLevelForCreate("ISOLATION_SERIALIZABLE");
|
||||
|
||||
// SQL Server 데이터베이스 타입 설정
|
||||
//factory.setDatabaseType(DatabaseType.SQLSERVER.getProductName());
|
||||
factory.setDatabaseType("sqlserver");
|
||||
factory.afterPropertiesSet();
|
||||
return factory.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* TaskExecutor for async batch processing
|
||||
*/
|
||||
@Bean
|
||||
public TaskExecutor batchTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(10);
|
||||
executor.setQueueCapacity(25);
|
||||
executor.setThreadNamePrefix("batch-");
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,8 @@ spring:
|
||||
batch:
|
||||
jdbc:
|
||||
initialize-schema: never
|
||||
table-prefix: BATCH_
|
||||
schema:
|
||||
job:
|
||||
names: ${job.name:NONE}
|
||||
enabled: false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user