Quartz为Grails工作只会触发一次 [英] Quartz job for Grails only fires once

查看:123
本文介绍了Quartz为Grails工作只会触发一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Quartz插件在我的Grails Web应用程序中设置一个cron作业。我目前只是简单地尝试使用以下代码每秒执行一次测试任务:

  class TestJob {
private int counter = 0
static triggers = {
simple repeatInterval:1000
}

def execute(){
//执行作业
counter + = 1
System.out.println(测试cron+计数器)
}
}
execute()的初始输出调用两次:一次立即在我收到服务器正在运行的提醒之前,以及之后立即发送一次。


  |加载Grails 2.1.0 
|配置类路径。
|环境设置为开发.....
|打包Grails应用程序.....
|编译1个源文件.....
|运行Grails应用程序
测试cron 1
|服务器运行。浏览到http:// localhost:8080 / QuartzTest
测试cron 1

有没有人知道为什么我的Quartz作业可能无法正确触发?我尝试过使用cron而不是简单的以及使用不同的参数,时间间隔等。没有任何改变。

谢谢

解决方案

我想我有类似的问题。您不得在石英作业中使用 System.out.println 。尝试使用 log.error


I am trying to setup a cron job in my Grails web application using the Quartz plugin. I am currently simply trying to get a test job to execute once every second using the following code:

class TestJob {
    private int counter = 0
    static triggers = {
        simple repeatInterval: 1000
    }

    def execute() {
        // execute job
        counter += 1
        System.out.println("Testing the cron " + counter)
    }
}

However, when I run the application I only see the initial output of the first execute() call twice: once immediately before I am alerted that the server is running, and once immediately after.

| Loading Grails 2.1.0
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 1 source files.....
| Running Grails application
Testing the cron 1
| Server running. Browse to http://localhost:8080/QuartzTest
Testing the cron 1

Does anyone know why my Quartz job might not be firing correctly? I have tried using a cron instead of simple as well as using varying parameters, time intervals, etc. Nothing has made a difference.

Thanks

解决方案

I think I had similar issues. You are not allowed to use System.out.println from within a quartz-job. Try to use log.error.

这篇关于Quartz为Grails工作只会触发一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆