byamabe
byamabe

Reputation: 1421

Periodic Task in Grails

I want to run a periodic task within a Grails application. Can anyone recommend a best practice for doing this?

Upvotes: 3

Views: 1030

Answers (2)

Jonathan Holloway
Jonathan Holloway

Reputation: 63734

A simple way to do this based on the core JDK libraries is via the TimerTask, that should allow you to setup a recurring event:

http://java.sun.com/javase/6/docs/api/java/util/TimerTask.html

There's a good IBM article here on using it for this purpose:

http://www.ibm.com/developerworks/java/library/j-schedule.html

If you want something more complex in terms of control then look at Quartz or Enterprise Quartz.

Upvotes: 1

John Wagenleitner
John Wagenleitner

Reputation: 11035

My recommendation would be the Quartz Plugin, here's a summary of the plugin from the site:

Quartz plugin allows your Grails application to schedule jobs to be executed using a specified interval or cron expression. The underlying system uses the Quartz Enterprise Job Scheduler configured via Spring, but is made simpler by the coding by convention paradigm.

Upvotes: 8

Related Questions