Let's say, i have a specific information in the database that needs to be sent for a specific user by email in a specific time of the day.
a) How can i create a routine in Grails, which is basically an action that is always running - without being associated with any event? Let's say, every hour that action is runned.
I was thinking about something like this:
while(true){
...
myCodeHere
...
wait 30minutes
}
Will this actually work? Without too much processing? And how can i have an action permanently running no matter what. I there is a specific way of doing this? Thanks in advanced, RR
Avoiding quartz and plugins you may use pure Spring Framework
1) add to container
(do not forget to define task and tx namespaces)
2) Create some bean and add method
finish! For more info see spring framework
The usual way to do this in a grails app is with the Quartz scheduler plugin. The plugin provides a simple cron-like DSL for scheduling jobs. For example, to run a job every 30 minutes, you could configure it like this:
If you want to run a background thread all the time, take a look at the executor plugin which provides an ExecutorService wrapped up properly to get a hibernate session.