首页 文章

Grails Quartz动态调度导入问题

提问于
浏览
0

我想使用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

    可能是你的工作是“包tao.marketing”,你的导入是“import jobs.tao.marketing . *”?我的意思是,进口从“工作”开始

  • 0

    我遇到的问题是,在我的STS IDE中,我没有将jobs目录标记为代码目录 . 谢谢你们的评论 .

相关问题