-
Notifications
You must be signed in to change notification settings - Fork 0
Asynchronous jobs
pramode edited this page Jun 28, 2011
·
1 revision
Under the app folder, create a file called "Bootstrap.java":
import play.jobs.*;
@Every("3s")
public class Bootstrap extends Job {
public void doJob() {
System.out.println("hello, job....");
}
}
~
The function "doJob" gets called every 3 seconds!
Execute a function on application start:
import play.jobs.*;
import models.*;
@OnApplicationStart
public class Startup extends Job {
public void doJob() {
if(Client.count() == 0) {
Client c = new Client();
c.name = "foo";
c.age = 76;
c.save();
}
}
This task will populate the database with one entry.