Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does each table for quartz scheduler signify?

There are few tables that quartz scheduler uses for scheduling jobs and to identify which job is running currently. It uses the following tables :

 qrtz_fired_triggers
 qrtz_simple_triggers
 qrtz_simprop_triggers
 qrtz_cron_triggers
 qrtz_blob_triggers
 qrtz_triggers
 qrtz_job_details
 qrtz_calendars
 qrtz_paused_trigger_grps
 qrtz_locks
 qrtz_scheduler_state

So what is the purpose of each of these tables and what does it siginifies?

Thanks in advance.

like image 762
Nakul Kumar Avatar asked Feb 01 '18 07:02

Nakul Kumar


People also ask

How does a quartz scheduler 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.

Does Quartz create tables automatically?

Quartz does not create the necessary tables in database automatically, you need to create them while application startup.

What is Quartz database?

Quartz is an open source job-scheduling framework written entirely in Java and designed for use in both J2SE and J2EE applications. It offers great flexibility without sacrificing simplicity. You can create complex schedules for executing any job.

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.


2 Answers

I had the chance to work on quartz recently. I'm myself not 100% clear on this topic and I'm going to try my best to answer your question from my personal experience.

You must remember this basic flow- 1. Create a job. 2. Create a Trigger. 3. Scheduler(job, trigger) All the above tables are based on the above 3 steps.

  1. qrtz_triggers is where general information of a trigger is saved.
  2. qrtz_simple_triggers, qrtz_simprop_triggers, qrtz_crons_triggers, qrtz_blob_triggers have a foreign key relation to qrtz_triggers which save those specific details. Ex. Cron has cron expression which is unique to it.
  3. qrtz_job_details is simply the task to be executed.
  4. qrtz_fired_triggers is a log of all the triggers that were fired.
  5. qrtz_paused trigger is to save the information about triggers which are not active.
  6. Calendars are useful for excluding blocks of time from the the trigger’s firing schedule. For instance, you could create a trigger that fires a job every weekday at 9:30 am, but then add a Calendar that excludes all of the business’s holidays. (taken from website. I havent' worked on it)
  7. I honestly haven't worked in qrtz_locks, qrtz_scheduler_sate tables.

Check out this image which I reverse engineered using MySQL workbench. enter image description here

like image 83
Kedar Avatar answered Oct 05 '22 23:10

Kedar


I can provide some inputs for qrtz_lock and qrtz_scheduler_sate tables:

  1. qrtz_lock stores the value of the instance name executing the job, to avoid the sceanario of multiple nodes executing the same job

  2. qrtz_scheduler_state is for capturing the node state so that if in any case one node gets down or failed to execute one of the job then the other instance running in clustering mode can pick the misfired job.

like image 20
chetan mahajan Avatar answered Oct 05 '22 23:10

chetan mahajan