Quartz work for Grails only works once

I am trying to configure cron to work in my Grails web application using the Quartz plugin . Currently, I'm just trying to run a test job once per 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 launch the application, I see only the first output of the first call execute()twice: once before I am notified that the server is working, 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 quartet performance may not work correctly? I tried using cron instead of simple, as well as using various parameters, time intervals, etc. Nothing has changed the situation.

thank

+5
source share
4

, . System.out.println . log.error.

+12

repeatCount. -1 :

simple name: "testName", repeatInterval: 1000, repeatCount: -1
+1

name :

static triggers = {
      simple name: "testName", repeatInterval: 1000      
}

, , , .

0

:

System.out.println Quartz Job. execute. , , :

class TestJob {
    static triggers = {
    simple name: 'testTrigger', startDelay: 1000, repeatInterval: 1000, repeatCount: -1
    }

    def execute() {
        exampleMethod()
        anotherMethod()
    }

    def exampleMethod(){
        System.out.println("test")
    }

    def anotherMethod(){
        System.out.println("another method")
   }
}

:

| Loading Grails 2.1.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 2 source files.....
| Running Grails application

Configuring Spring Security UI ...
... finished configuring Spring Security UI


Configuring Spring Security Core ...
... finished configuring Spring Security Core

test
another method
| Server running. Browse to http://localhost:8080/
test
another method
test
another method
test
another method
test
another method
test
another method

Hope this helps someone!

0
source

All Articles