0
votes

In my project I required to write some background jobs for scheduled processing. I did it using quartz scheduler with spring, but quite often it required me to execute the tasks at random without schedule. So later I pulled out the tasks from the quartz and created web endpoints for them(exposed internally).

To perform the regular scheduled based operation of tasks, I created unix cron jobs that hit the web endpoints using curl command.

My question is, why could this approach not work always. Even in case you don't want to expose web endpoints, you can always execute standalone tasks using unix cron. Is there any particular advantage I gain by using quartz scheduler over unix cron jobs?

1

1 Answers

3
votes

You may still opt for using Quartz if:

  • An event needs to be scheduled as part of the activity that happens within the java application itself. For example, user subscribes to a newsletter.
  • You have a listener object that needs to be notified when the job completes.
  • You are using JTA transactions in your scheduled job
  • You want to keep the history of job executions or load job and trigger definitions from a file or a database
  • You are running on an application server and require load balancing and failover
  • You are not running on an UNIX / Linux environment (i.e. you wanted platform independence)