Quartz2 - Simple example

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Quartz2 - Simple example

calvinthomas@gmail.com
Hi all -

Has anyone managed to get the quartz2 plugin working who may be able to give me a really simple example that I can use to get myself going? Following the example in the documentation, I have added the following to Config.groovy:

grails.config.locations = ["file:Quartz-config.groovy"]

and put the file Quartz-config.groovy in the same folder containing the following:

grails.plugin.quartz2.autoStartup = true

org{
        quartz{
                //anything here will get merged into the quartz.properties so you don't need another file
                scheduler.instanceName = 'MyAppScheduler'
                threadPool.class = 'org.quartz.simpl.SimpleThreadPool'
                threadPool.threadCount = 20
                threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
                jobStore.class = 'org.quartz.simpl.RAMJobStore'
        }
}

//you can drive the setup. just give them a unique key like "buyTheTicket" below.
//the quartzScheduler bean and application context are passed to your closure
grails.plugin.quartz2.jobSetup.hello = { quartzScheduler, ctx ->
        //how it should look
        def jobDetail = ClosureJob.createJob { jobCtx , appCtx->
                appCtx.TestService.test()
        }

        def trigger1 = new SimpleTriggerImpl(name:"trig1", startTime:new Date()-1,repeatInterval:1000,repeatCount:-1)

        quartzScheduler.scheduleJob(jobDetail, trigger1)
}


Then I have created the TestService and the test method to simply print out some text, i.e.

class TestService {

    def test() {
        println "Test"
    }
}


Unfortunately with this I don't get any output at all and am unsure of how to go about logging for this to try to get anything from that.

Many thanks for any advice you can offer.

Calvin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quartz2 - Simple example

Kafka Liu
The same problem to u. Anybody can help? Thx!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quartz2 - Simple example

Kafka Liu
In reply to this post by calvinthomas@gmail.com
Found the workaround method. You may put the job code down in Config.groovy instead of external groovy file.
Loading...