Does DropWizard natively support scheduled tasks?

IAmYourFaja picture IAmYourFaja · Dec 21, 2014 · Viewed 9k times · Source

DropWizard allows you to define administrative tasks and execute them remotely by hitting a URL. DropWizard apps also have a few built-in admin tasks, such as the Garbage Collector, which can be hit by sending a GET to http(s)://yourapp.example.com:8081/tasks/gc.

I'm wondering if DropWizard has any built-in support for scheduling tasks. For instance, using the GC task as an example, it might be nice to schedule garbage collection every 3 hours, or at midnight, etc.

Obviously, I could incorporate something like Quartz to achieve this, but why reinvent the wheel if I DropWizard already natively supports this out of the box? So does it?

Answer

Mirko Adari picture Mirko Adari · Dec 21, 2014

While DropWizard is pretty great at having everything you might need available, they don't have this. Probably because it is pretty easy to just use JDK APIs to schedule simple things.

However, there are a lot of services available for DropWizard that provide a nice integration with Quartz etc. One example is here https://github.com/spinscale/dropwizard-jobs.

Check this thread for more ideas on what other people in a similar situation have done -- https://groups.google.com/forum/#!topic/dropwizard-user/WmDjhWsms8I.