我是工作安排的新手。 我正在尝试在crystal和org.quartz.impl.StdScheduler的帮助下以递归方式执行特定任务。
我具有以下qartz设置和spring依赖注入-定义Scheduler Server Bean。
玉米exp-0 * / 5 *吗? * *-每5分钟
Properties quartzProperties = new Properties();
quartzProperties.put("rg.quartz.scheduler.instanceName","UnicaScheduler");
quartzProperties.put("org.quartz.scheduler.skipUpdateCheck","true");
quartzProperties.put("org.quartz.threadPool.class","org.quartz.simpl.SimpleThreadPool");
quartzProperties.put("org.quartz.threadPool.threadCount","10");
quartzProperties.put("org.quartz.threadPool.threadPriority","5");
quartzProperties.put("org.quartz.scheduler.instanceId","AUTO");
quartzProperties.put("org.quartz.jobStore.misfireThreshold","60000");
quartzProperties.put("org.quartz.jobStore.class","org.quartz.impl.jdbcjobstore.JobStoreTX");
quartzProperties.put("org.quartz.jobStore.lockHandler.class","org.quartz.impl.jdbcjobstore.UpdateLockRowSemaphore");
quartzProperties.put("org.quartz.jobStore.driverDelegateClass",getDBProductName().getDriverDelegateName());
quartzProperties.put("org.quartz.jobStore.useProperties","false");
quartzProperties.put("org.quartz.jobStore.tablePrefix","QRTZ_");
quartzProperties.put("org.quartz.jobStore.selectWithLockSQL","SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
quartzProperties.put("org.quartz.jobStore.isClustered",Boolean.toString(AMConfigDB.getInstance().isClustered()));
quartzProperties.put("org.quartz.plugin.shutdownhook.class","org.quartz.plugins.management.ShutdownHookPlugin");
quartzProperties.put("org.quartz.plugin.shutdownhook.cleanShutdown","true");
DataSource dataSource = (DataSource)applicationContext.getBean(DATASHOURCE_BEAN_NAME);
MutablePropertyValues schedulerFactoryProperties = new MutablePropertyValues();
schedulerFactoryProperties.addPropertyValue("dataSource", dataSource);
schedulerFactoryProperties.addPropertyValue("startupDelay", "10");
schedulerFactoryProperties.addPropertyValue("quartzProperties", quartzProperties);
schedulerFactoryProperties.addPropertyValue("autoStartup", "true");
LOG.debug("Starting the Scheduler factory bean with properties as " +quartzProperties);
RootBeanDefinition beanDefinition = new RootBeanDefinition(SchedulerFactoryBean.class);
beanDefinition.setPropertyValues(schedulerFactoryProperties);
DefaultListableBeanFactory beanFactory=(DefaultListableBeanFactory)applicationContext.getBeanFactory();
beanFactory.registerBeanDefinition(SCHEDULER_BEAN_NAME, beanDefinition);
beanFactory.initializeBean(beanDefinition, SCHEDULER_BEAN_NAME);
defineSchedulerServerDependencies();
// starting the scheduler..
LOG.debug("Starting the scheduler server.");
StdScheduler schedulerFactoryBean = (StdScheduler)applicationContext.getBean(SCHEDULER_BEAN_NAME);
schedulerFactoryBean.start();
LOG.warn("Scheduler metadata : " + ((StdScheduler) applicationContext.getBean(SCHEDULER_BEAN_NAME)).getMetaData().getSummary());
我尝试每5分钟运行一次任务,它运行正常,每5分钟运行一次。
说,我是从10:00 AM开始的,它的递归发生率是10.00,10.05,10.10 ...等等。
问题是,当我在例如10.16之间将其停止,然后将其重新启动到10.21时,这就是问题所在,在10.21(重新启动后)将有两个作业计划,分别是10.21(意外),下一个是10.25(预期) )。
我应该怎么做才能在10.25执行作业,而不是在10.21重新启动时执行作业。
请帮助。