protected Scheduler createScheduler(String name, int threadPoolSize) throws SchedulerException {
try {
this.taskSchedulerHelper = new TaskSchedulerHelper(database.getInstance());
this.taskSchedulerHelper.init(threadPoolSize, new SimpleJobFactory());
this.taskSchedulerHelper.start();
return ((QuartzSchedulerSPI) taskSchedulerHelper.getScheduler()).getScheduler();
}
catch (Exception e) {
Throwables.throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
scheduler.setTaskExecutor(getAsyncExecutor());
scheduler.setAutoStartup(true);
scheduler.setJobFactory(new SimpleJobFactory());
return scheduler;
}