Java – Spring Scheduling: @Scheduled vs Quartz

javaquartz-schedulerschedulingspring

I'm reading the Spring 3.0 docs regarding scheduling. I'm leaning towards Spring's JobDetailBean for Quartz. However, the @Scheduled annotation has captured my eye. It appears this is another way of scheduling task using the Spring Framework. Based on the docs, Spring provides three way of scheduling:

  1. @Scheduled
  2. Via Quartz
  3. Via JDK Timer

I have no interest in the JDK Timer. Why should I choose @Scheduled over Quartz? (When I mention Quartz I mean using Spring's bean wrapper for Quartz).

Let's say my use case is complex enough that I will be communicating to a third-party web service to import and export data at specified intervals.

Best Answer

Quartz is an order of magnitude more complex than Spring's built in scheduler, including support for persistent, transactional and distributed jobs. It's a bit of a pig, though, even with Spring's API support.

If all you need to is to execute methods on a bean every X seconds, or on a cron schedule, then @Scheduled (or the various options in Spring's <task> config schema) is probably enough