I've recently released a project called
dropwizard-sundial, which nicely integrates Sundial into a Dropwizard app, adding many new convenient features. With [dropwizard-sundial](
https://github.com/timmolter/dropwizard-sundial), you can easily integrate the lightweight multi-threaded Java job scheduling library, [Sundial](
https://github.com/timmolter/Sundial), and add Jobs either using a `SimpleTrigger` or a `CronTrigger`. First, you'd start out with a class defining your job logic with a `SimpleTrigger` annotation:
@SimpleTrigger(repeatInterval = 60, timeUnit = TimeUnit.SECONDS)
public class SampleJob extends com.xeiam.sundial.Job {
@Override
public void doRun() throws JobInterruptException {
// Do something interesting...
}
}
A `CronTrigger` annotation is also available (@CronTrigger(cron = "0/5 * * * * ?")). In your Dropwizard app's `yaml` file, you'll need to define what package `dropwizard-sundial` should search for annotated job classes. Following is an example config with the `annotated-jobs-package-name` config param along with several other optional params for fine-tuning the scheduler:
sundial:
thread-pool-size: 10
shutdown-on-unload: true
wait-on-shutdown: false
start-delay-seconds: 0
start-scheduler-on-load: true
global-lock-on-load: false
annotated-jobs-package-name: com.foo.bar.jobs
Additionally, you can control the scheduler asynchronously via Curl while the app is running to do things like locking and unlocking the scheduler, starting, stopping, adding, removing jobs and triggers. Here are a few examples: