ScheduleConfig.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //package com.jjt.quartz.config;
  2. //
  3. //import org.springframework.context.annotation.Bean;
  4. //import org.springframework.context.annotation.Configuration;
  5. //import org.springframework.context.annotation.Profile;
  6. //import org.springframework.scheduling.quartz.SchedulerFactoryBean;
  7. //
  8. //import javax.sql.DataSource;
  9. //import java.util.Properties;
  10. //
  11. ///**
  12. // * 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
  13. // *
  14. // * @author jjt
  15. // */
  16. //@Configuration
  17. //@Profile({"!junit","!jt"})
  18. //public class ScheduleConfig {
  19. // @Bean
  20. // public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
  21. // SchedulerFactoryBean factory = new SchedulerFactoryBean();
  22. // factory.setDataSource(dataSource);
  23. //
  24. // // quartz参数
  25. // Properties prop = new Properties();
  26. // prop.put("org.quartz.scheduler.instanceName", "JjtScheduler");
  27. // prop.put("org.quartz.scheduler.instanceId", "AUTO");
  28. // // 线程池配置
  29. // prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
  30. // prop.put("org.quartz.threadPool.threadCount", "20");
  31. // prop.put("org.quartz.threadPool.threadPriority", "5");
  32. // // JobStore配置
  33. // prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
  34. // // 集群配置
  35. // prop.put("org.quartz.jobStore.isClustered", "true");
  36. // prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
  37. // prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "10");
  38. // prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
  39. //
  40. // // sqlserver 启用
  41. // // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
  42. // prop.put("org.quartz.jobStore.misfireThreshold", "12000");
  43. // prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
  44. // factory.setQuartzProperties(prop);
  45. //
  46. // factory.setSchedulerName("JjtScheduler");
  47. // // 延时启动
  48. // factory.setStartupDelay(1);
  49. // factory.setApplicationContextSchedulerContextKey("applicationContextKey");
  50. // // 可选,QuartzScheduler
  51. // // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
  52. // factory.setOverwriteExistingJobs(true);
  53. // // 设置自动启动,默认为true
  54. // factory.setAutoStartup(true);
  55. //
  56. // return factory;
  57. // }
  58. //}