package cn.lihu.jh.module.ecg.config;
|
|
import cn.lihu.jh.module.ecg.service.queue.QueueService;
|
import cn.lihu.jh.module.ecg.service.room.RoomService;
|
import cn.lihu.jh.module.infra.api.config.ConfigApi;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
|
import javax.annotation.Resource;
|
import java.util.concurrent.Executors;
|
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
@Configuration
|
@EnableScheduling
|
public class DynamicSchedulingConfig implements SchedulingConfigurer {
|
|
public static ScheduledTaskRegistrar static_scheduledTaskRegistrar;
|
|
@Override
|
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
DynamicSchedulingConfig.static_scheduledTaskRegistrar = taskRegistrar;
|
|
ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
|
scheduledThreadPoolExecutor.setRemoveOnCancelPolicy(true);
|
taskRegistrar.setScheduler(scheduledThreadPoolExecutor);
|
}
|
}
|