Grails Quartz动态调度导入问题

时间:2014-11-01 09:16:34

标签: grails quartz-scheduler grails-plugin jobs

我想使用Grails quartz插件的动态调度功能。

我正在运行grails 2.3.5和石英插件(quartz:1.0.2)。

我能够将石英信息保存到我的mysql数据库中,并且能够运行普通的石英作业。

问题是动态调度任务。我没有让它发挥作用。

以下是我的设置以及我要做的事情:

我在"grails-app/tao/marketing/MarketingJob"中有一个简单的工作,如下所示:

package tao.marketing
import org.quartz.JobExecutionContext; 
import org.quartz.JobExecutionException; 

class MarketingJob {

static triggers ={}

def execute(JobExecutionContext context) {
     try{
        def today = new Date()
        println today
    }
    catch (Throwable e) {
       throw new JobExecutionException(e.getMessage(), e);
    }
  }
}

我现在尝试从服务中动态安排。

package tao

import grails.transaction.Transactional
import tao.marketing.CampaignSchedule
import tao.Person
import jobs.tao.marketing.*



class ScheduleService {

def scheduleMarketingForPerson(CampaignSchedule campaignSchedule, Person person) {
    log.info("Schedule new Marketing for: "+person.last_name)
        campaignSchedule.scheduleActions.each {
            Date today = new Date();
            Date scheduleDate = today+it.afterXdays
            log.info("ScheduleAction: "+it.id+": "+scheduleDate)
            MarketingJob.schedule(scheduleDate, ["scheduleActions.id":it.id,     "person.apiKey":person.apiKey])
        }
    }
}

在我的IDE(STS)MarketingJob中找不到。

 MarketingJob.schedule(scheduleDate, ["scheduleActions.id":it.id,     "person.apiKey":person.apiKey])

如何正确导入标记作业? 我是否正确了解动态调度功能?

2 个答案:

答案 0 :(得分:0)

可能是你的工作在"包tao.marketing"并且您的导入是" import jobs.tao.marketing。*"?我的意思是,导入从" jobs"

开始

答案 1 :(得分:0)

我遇到的问题是,在我的STS IDE中,我没有将jobs目录标记为代码目录。感谢您的所有意见。