ECM
ECM
总版主
总版主
  • 社区居民
  • 忠实会员
  • 原创写手
阅读:1037回复:0

How to migrate from RAMJobStore to JobStoreCMT for persisted Quartz jobs in Seam

楼主#
更多 发布于:2016-05-16 10:53
I am trying to get a simple example of the Quartz scheduler working in JBoss Seam 2.2.0.GA. Everything works fine using the RAMJobStore setting, but changing the store from org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
 to org.quartz.jobStore.class org.quartz.impl.jdbcjobstore.JobStoreCMT
org.quartz.jobStore.driverDelegateClass org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.useProperties false
org.quartz.jobStore.dataSource quartzDatasource
## FIXME Should be a different datasource for the non managed connection.
org.quartz.jobStore.nonManagedTXDataSource quartzDatasource
org.quartz.jobStore.tablePrefix qrtz_
org.quartz.dataSource.quartzDatasource.jndiURL java:/quartzDatasource
 allows the scheduler to start up, but whereas the job was previously being triggered and run at the correct interval, now it is not run at all. There is also nothing persisted to the quartz database. I am aware that the nonManagedTXDataSource shouldn't be the same as the managed datasource, but I am having issues with the datasource being unable to be found by Quartz, even though there is a message earlier on reporting it being bound successfully (this is probably about to be asked in a separate question). Using the same datasource allows the service to start up without errors. My components.xml file has the following: <event type="org.jboss.seam.postInitialization">
   <action execute="#{asyncResultMapper.scheduleTimer}"/>
</event>
<async:quartz-dispatcher/>
 and ASyncResultMapper has the following: @In
ScheduleProcessor processor;
private String text = "ahoy";
private QuartzTriggerHandle quartzTriggerHandle;

public void scheduleTimer() {
    String cronString = "* * * * * ?";
    quartzTriggerHandle = processor.createQuartzTimer(new Date(), cronString, text);
}
 and ScheduleProcessor is as follows: @Name("processor")
@AutoCreate
@Startup
@Scope(ScopeType.APPLICATION)
public class ScheduleProcessor {

    @Asynchronous
    public QuartzTriggerHandle createQuartzTimer(@Expiration Date when, @IntervalCron String interval, String text) {
        process(when, interval, text);
        return null;
    }

    private void process(Date when, String interval, String text) {
        System.out.println("when = " + when);
        System.out.println("interval = " + interval);
        System.out.println("text = " + text);
    }
}
 The logs show the service starting but nothing about the job: INFO  [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
INFO  [JobStoreCMT] Using db table-based data access locking (synchronization).
INFO  [JobStoreCMT] Removed 0 Volatile Trigger(s).
INFO  [JobStoreCMT] Removed 0 Volatile Job(s).
INFO  [JobStoreCMT] JobStoreCMT initialized.
INFO  [JobStoreCMT] Freed 0 triggers from 'acquired' / 'blocked' state.
INFO  [JobStoreCMT] Recovering 0 jobs that were in-progress at the time of the last shut-down.
INFO  [JobStoreCMT] Recovery complete.
INFO  [JobStoreCMT] Removed 0 'complete' triggers.
INFO  [JobStoreCMT] Removed 0 stale fired job entries.
INFO  [QuartzScheduler] Scheduler FlibScheduler$_NON_CLUSTERED started.
 I'm sure it's probably something trivial I've missed, but I can't find a solution in the forums anywhere.
answer(解决方案):

Managed to solve this for myself in the end. The issue of the JobStoreCMT version not starting and triggering jobs was caused by a mixture of a missing @Transactional (thanks tair), and more importantly a need to upgrade Quartz. Once Quartz was upgraded to 1.8.5 the error messages became a lot more useful.

 

 

 

 

 

 

 

异常中心网是一家专门收集整理程序员编程过程中遇到的常见异常(exception)以及各种异常问答中心的网站。异常中心网旨在,减少程序员在编码遇到异常,处理各种异常时间和痛苦,让程序员能更愉快的、快速的定位异常并查找对应的异常解决方案。异常中心网诚心打造最完美的编程社区为程序员用户服务,努力成为最好的程序员乐园程序员社区程序异常中心程序bug中心异常问答中心

 

喜欢0 评分0
游客

返回顶部