使用石英调度程序插件(v1.0.1)处理grails并使用相同的代码执行石英作业:
import java.util.logging.Logger
import org.quartz.DisallowConcurrentExecution
import org.quartz.Job
import org.quartz.JobExecutionContext
import org.quartz.JobExecutionException
import org.quartz.PersistJobDataAfterExecution
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
class AccountingWatchJob implements Job {
def sessionRequired = false
def concurrent = false
def volatility = false
def group = "AccountingProcess"
def accountingWatchService
static triggers = {
// daily at 5:00 am
cron name:'triggerPayment', startDelay:300000, cronExpression: '0 0 5 * * ?'
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
try {
accountingWatchService.start()
} catch (Throwable e) {
log.error(e)
}
}
}
仅在生产模式中出现错误=>
[quartzScheduler_Worker-1] ERROR grails.app.jobs.com.ubiness.ubistore.AccountingWatchJob - java.lang.reflect.UndeclaredThrowableException