Şu satırı dahil ederiz
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
Örnek
Şöyle yaparız
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
@Configuration
public class QuartzConfig {
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setJobFactory(new SpringBeanJobFactory());
factory.setDataSource(dataSource); // Inject your data source here
factory.setQuartzProperties(quartzProperties());
factory.setOverwriteExistingJobs(true);
factory.setWaitForJobsToCompleteOnShutdown(true);
return factory;
}
// Configure Quartz properties (e.g., thread count, clustering, etc.)
private Properties quartzProperties() {
Properties properties = new Properties();
properties.setProperty("org.quartz.scheduler.instanceName", "MyScheduler");
properties.setProperty("org.quartz.scheduler.instanceId", "AUTO");
// Set the number of worker threads
properties.setProperty("org.quartz.threadPool.threadCount", "5");
properties.setProperty("org.quartz.jobStore.isClustered", "true");
// Interval for cluster node check-in
properties.setProperty("org.quartz.jobStore.clusterCheckinInterval", "2000");
properties.setProperty("org.quartz.jobStore.class",
"org.quartz.impl.jdbcjobstore.JobStoreTX");
properties.setProperty("org.quartz.jobStore.driverDelegateClass",
"org.quartz.impl.jdbcjobstore.StdJDBCDelegate");
properties.setProperty("org.quartz.jobStore.tablePrefix", "QRTZ_");
return properties;
}
}
Hiç yorum yok:
Yorum Gönder