Open eunja511005 opened 1 year ago
drop table ZTHM_BATCH_MASTER;
CREATE TABLE ZTHM_BATCH_MASTER (
id VARCHAR2(200),
batch_name VARCHAR2(255) NOT NULL,
description VARCHAR2(1000) NOT NULL,
batch_cycle NUMBER NOT NULL,
start_date TIMESTAMP(6),
end_date TIMESTAMP(6),
status VARCHAR2(50),
manager VARCHAR2(100),
log_yn CHAR(1),
del_yn CHAR(1),
create_id VARCHAR2(50),
create_dt TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
update_id VARCHAR2(50),
update_dt TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_zthm_batch_master PRIMARY KEY (id)
);
@Configuration
public class ThreadPoolConfig {
@Bean
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10); // 기본적으로 유지할 스레드 수
executor.setMaxPoolSize(20); // 최대 스레드 수
executor.setQueueCapacity(500); // 대기열 크기
executor.setThreadNamePrefix("MyThreadPool-");
executor.initialize();
return executor;
}
}
@Component
public abstract class BatchWorker implements Runnable{
@Autowired
protected BatchMasterService batchMasterService;
protected BatchMasterDTO batchMasterDTO;
public void setBatchMasterDTO(BatchMasterDTO batchMasterDTO) {
this.batchMasterDTO = batchMasterDTO;
}
@Override
public void run() {
// 배치 수행중 상태로 변경
batchMasterService.updateBatchMasterInprogress(batchMasterDTO);
doBatch();
// 배치 실행 가능 상태로 변경
batchMasterService.updateBatchMasterReady(batchMasterDTO);
}
public abstract void doBatch();
}
@Component
@RequiredArgsConstructor
public class SendMessageBatchWorker extends BatchWorker {
public void doBatch() {
}
}
개요