【发布时间】:2016-08-07 16:06:37
【问题描述】:
我正在使用 Grails 3.0.12,我正在使用 Quartz 执行一项工作,我现在尝试做的是每次发送一封电子邮件(在这种情况下每 5 秒)。我的服务文件夹中有电子邮件服务。这是我的代码:
class EnviaCorreosJob{
NotifierService notificar
Integer diasParaCorreo = 30
static triggers =
{
cron name: 'myTrigger', cronExpression: "*/5 * * * * ?"
}
def group = "MyGroup"
def description = "Example job with Cron Trigger"
def fechaHoy = new Date()
def execute()
{
println "------------------ Running every 5 seconds -------------------"
def queryAgenda = Agenda.where
{
inicio_cita <= (fechaHoy + diasParaCorreo)
}
def listaAgenda = queryAgenda.list()
println "----------------------Dates list : " + listaAgenda
log.info "listaAgenda: " + listaAgenda
log.info "listaAgendaTamaño: " + listaAgenda.size()
listaAgenda.each
{
agenda ->
println "it's inside"
mailService.sendMail
{
to "xxxxxx@gmail.com"
subject "hello"
body "hello"
}
}
}
}
我尝试创建一个 Service 类的实例来调用 mailService.sendMail 但没有成功。
非常感谢您的帮助。 :)
【问题讨论】:
标签: hibernate grails orm quartz-scheduler