Job helper for Play framework 2.2.x Java.
This plugin is inspired by the Job API in Play 1.2.x. The goal is to make it easy to setup recurring jobs and manually start jobs when needed.
To use jobs extend plugins.jobs.Job<T>
in a class, you can use the @On
or @Every
annotations to
setup recurring jobs or start the jobs manually calling Job.now()
or Job.in("5min")
.
@On("0 0 0 * * ?")
..* Use cron style expressions@Every("30min")
..* Examples: "1h", "30min", "15s", "1h 15min"...
import plugins.jobs.Job;
import plugins.jobs.On;
@On("0 0 0 * * ?")
public class MyJob extends Job<Void>
{
@Override
public Void run() throws Exception
{
// Implement job here...
return null;
}
}
import plugins.jobs.Job;
import plugins.jobs.Every;
@Every("30min")
public class EveryJob extends Job<Void>
{
@Override
public Void run() throws Exception
{
// Implement job here...
return null;
}
}
- Local setup
..* Checkout the repository and publish locally (start play and run
compile
andpublishLocal
). ..* Add dependency to your app by adding"default" % "play2-jobs_2.10" % "0.1"
to build.sbt.