What are the main components, when using quartz in java?

Ans. The scheduler, job and trigger. The scheduler coordinates the execution of the job and the trigger sets up the interval and frequency with which the job will run.

How do you start a quartz process which will start executing jobs?
Ans. To begin a quartz process you must initiate all the components, scheduler, job and trigger, and then call the start method on the scheduler.
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("jcgTriggerName", "group1")
  .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?")).build();
Scheduler scheduler;
scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
JobKey jobKey = new JobKey("jcgJobName", "group1");
JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity(jobKey).build();
scheduler.scheduleJob(job, trigger);

How to check the status of a running quartz job?

Ans. The JobListener will allow you to check the status of a running job.

jcgScheduler.getListenerManager().addJobListener(jcgJobListener, KeyMatcher.jobKeyEquals(new JobKey("jcgJobName", "jcgJobGroup")));

 

How is the SimpleTrigger used?

Ans. A SimpleTrigger is used for a single execution or an execution that repeated a specific number of times over a given interval.

 

How do personalize or customize thread management?

Ans. I set the thread pool class and corresponding thread pool properties that fall under org.quartz.threadPool. The default thread pool is org.quartz.simpl.SimpleThreadPool.

 

what is the use of the CronTrigger?

Ans. The CronTrigger is used to execute a job using a cron expression. A cron expression is a notation that represents a second, minute, hour, day, month, or year as well as the ways to express special characters like wildcards or ranges for the schedule.

 

How to store job state in Quartz?

AnsThe JobDataMap is used to store state that will be provided to the job when it executes.

 

How do you handle or prevent concurrent execution of jobs?

Ans. The DisallowConcurrentExecution annotation is used to prevent concurrent execution of that same instance of jobs. The instance definition is controlled by the identifier in JobDetail.

 

How do you update the JobDataMap between execution of jobs?

Ans. Use the PersistJobDataAfterExecution annotation to update the data in JobDataMap after the job executes successfully.

 

What are the different types of exceptions allowed in the job execute method?

Ans. The JobExecutionException is the only allowable exception from the job execute method

 

What happens when a scheduled job fails to trigger?

Ans. The misfire conditions is specific to each trigger. For the cron trigger, a misfire condition is specified in the job creation or will default to the smart policy. To customize the misfire condition specific to the cron trigger there are three options; withMisfireHandlingInstructionDoNothing, withMisfireHandlingInstructionFireAndProceed, withMisfireHandlingInstructionIgnoreMisfires.

You can also create a custom trigger by implementing the TriggerListener interface and define the triggerMisfired method.

public void triggerMisfired(Trigger trigger);

 

What are the different job stores available in Quartz?

Ans. Job stores control how data is provided to the scheduler, jobs, and triggers.

 

What are different types of Job Stores available in Quartz?

Ans. There are three different types of job stores provided by quartz; RAMJobStore, JDBCJobStore and TerracottaJobStore that provided persistent job data to quartz components.

 

How to stop a running job?

Ans. You can stop a running job by calling interrupt on the scheduler and providing the job key. The job that you are interrupting must implement the InterruptableJob interface.

sched.interrupt(job.getKey());

What is the JobExecutionContext?

Ans. The JobExecutionContext is passed to the execute method of an invoked job by the scheduler and it contains a handle to the scheduler, a handle to the trigger and the JobDetail.

 

Write down some bundled Jobs that quartz provides?

Ans. A few of the jobs that quartz provides for users are FileScanJob, DirectoryScanJob, NativeJob, EJB3InvokerJob, SendQueueMessageJob, SendTopicMessageJob, JmxInvokerJob and SendMailJob. Documentation on these jobs exists in the JavaDoc for the quartz-jobs-*.jar.