2013-04-23 40 views
0

我有一個集羣Quartz(版本2.1.6)調度程序,似乎在部署到websphere集羣時可以正常工作。調度器由Spring創建(版本3.1.3_RELEASE)。Spring JDBC存儲SchedulerFactoryBean無法手動觸發存儲的觸發器

<bean id="scheduler-JDBC" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" abstract="true"> 
    <property name="dataSource" ref="myDataSource" /> 
    <property name="transactionManager" ref="transactionManager" /> 
    <property name="jobFactory"> 
     <bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory" /> 
    </property> 
    <property name="overwriteExistingJobs" value="true" /> 
    <property name="quartzProperties"> 
     <props> 
      <prop key="org.quartz.jobStore.isClustered">true</prop>    
      <prop key="org.quartz.jobStore.driverDelegateClass">${org.quartz.jobStore.driverDelegateClass}</prop> 
      <prop key="org.quartz.scheduler.instanceId">AUTO</prop> 
      <prop key="org.quartz.scheduler.skipUpdateCheck">true</prop> 
     </props> 
    </property> 
</bean> 

<bean id="cronScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" parent="scheduler-${scheduler:RAM}" depends-on="quartzDatabaseInitializer"> 
    <property name="startupDelay" value="10" /> 
    <property name="autoStartup" value="true" /> 
    <property name="applicationContextSchedulerContextKey" value="applicationContext"/> 
    <property name="triggers"> 
     <list> 
      <ref bean="cronTriggerStats" />    
     </list> 
    </property> 
</bean> 

觸發器和作業存儲在數據庫中。作業是使用job_name =「serverStatsJob」和job_group =「DEFAULT」創建的。觸發器每20分鐘執行一次。 如何手動觸發作業?

我已經試過

StdScheduler cronScheduler = (StdScheduler)springContext.getBean("cronScheduler"); 
cronScheduler.triggerJob(new JobKey("serverStatsJob", "DEFAULT")); 

如果我使用一個RAM存儲,而不是JDBC其中工程

我也試圖與存儲的作業

Trigger trigger1 = newTrigger() 
.withIdentity("serverStatsJobTrigger", "userRequested") 
.withSchedule(simpleSchedule() 
.withRepeatCount(0)) 
.startNow() 
.forJob(new JobKey("serverStatsJob", "DEFAULT")) 
.build(); 
cronScheduler.scheduleJob(trigger1); 

但是,創造一個新的觸發它也不起作用。 有人能幫我嗎

回答

0

我自己發現了這個問題。 調度程序未正確執行事務。

我爲調度程序添加了<tx:advice>,現在它工作。

<aop:config> 
    <aop:pointcut id="quartzSchedulerPointcut" expression="execution(* org.quartz.Scheduler.*(..))" /> 
    <aop:advisor advice-ref="quartzSchedulerAdvice" pointcut-ref="quartzSchedulerPointcut" /> 
</aop:config> 

<tx:advice id="quartzSchedulerAdvice" transaction-manager="transactionManager"> 
    <tx:attributes> 
     <tx:method name="*"/> 
    </tx:attributes> 
</tx:advice> 
相關問題