Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the quartz scheduler work? [closed]

My question is : How does the quartz scheduler work and how is it different from a normal class implementing the Runnable interface (basically a thread) which wakes up according to the specified time interval and performs the required job?

Is it just a convenient way of doing things (using the quartz scheduler) like specifying the job configuration through an XML files and easy addition of new jobs to an existing scheduler or is there something more to it? By more, I mean does it do any sort of optimizations such as it does not hang on to the thread for the entire duration and releases it? Is it a polling kind of mechanism where the thread keeps polling the system time and sees whether the specified time interval has elapsed or does it do some kind of registration with the system clock where the clock itself notifies the quartz scheduler?

Please let me know if any further clarification is required on the question above.

like image 288
Abhishek Jain Avatar asked Oct 16 '12 06:10

Abhishek Jain


People also ask

How does Quartz scheduling work?

Quartz scheduler allows an enterprise to schedule a job at a specified date and time. It allows us to perform the operations to schedule or unschedule the jobs. It provides operations to start or stop or pause the scheduler. It also provides reminder services.

How do you turn off a quartz scheduler?

We disable the quartz scheduler locally by commenting out the scheduler factory bean in the jobs. xml file.

How does Quartz clustering work?

Quartz's clustering features bring both high availability and scalability to your scheduler via fail-over and load balancing functionality. Clustering currently only works with the JDBC-Jobstore (JobStoreTX or JobStoreCMT), and essentially works by having each node of the cluster share the same database.

How many jobs can Quartz handle?

The actual number of jobs that can be running at any moment in time is limited by the size of the thread pool. If there are five threads in the pool, no more than five jobs can run at a time.


1 Answers

After posting the question, I browsed through some content on the web and found some useful insights into the same. Sorry for posting a question and answering it myself, but it would be useful for anybody else who may like to understand the same.

Here are the benefits of Quartz and its comparison with the usual Java timer interface:

  • Quartz is quite flexible, and contains multiple usage paradigms that can be used separately or together, in order to achieve your desired behavior, and enable you to write your code in the manner that seems most 'natural' to your project.
  • Quartz is very light-weight, and requires very little setup/configuration - it can actually be used 'out-of-the-box' if your needs are relatively basic.
  • Quartz is fault-tolerant, and can persist ('remember') your scheduled jobs between system restarts.

On the other hand, it overcomes the following problems in the Timer interface:

  • Timers have no persistence mechanism.
  • Timers have inflexible scheduling (only able to set start-time & repeat interval, nothing based on dates, time of day, etc.)
  • Timers don't utilize a thread-pool (one thread per timer)
  • Timers have no real management schemes - you'd have to write your own mechanism for being able to remember, organize and retrieve your tasks by name, etc.

If anybody would like to add any info to the above, please feel free to do so.

like image 71
Abhishek Jain Avatar answered Oct 19 '22 23:10

Abhishek Jain