Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Name A Few Of The Bundled Jobs That Quartz Provides?

Answer»

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.

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.

2.

What Is The Jobexecutioncontext?

Answer»

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.

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.

3.

How Would You Stop A Running Job?

Answer»

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.

  1. sched.interrupt(job.getKey());

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.

4.

What Are Different Types Of Job Stores?

Answer»

There are three different TYPES of JOB STORES provided by QUARTZ; RAMJobStore, JDBCJobStore and TerracottaJobStore that provided persistent job data to quartz COMPONENTS.

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

5.

What Are Job Stores?

Answer»

JOB stores control how DATA is PROVIDED to the scheduler, jobs, and TRIGGERS.

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

6.

What Happens When A Scheduled Job Fails To Trigger?

Answer»

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.

1 public void triggerMisfired(Trigger trigger);

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.

1 public void triggerMisfired(Trigger trigger);

7.

What Types Of Exceptions Are Allowed From The Job Execute Method?

Answer»

The JobExecutionException is the only allowable exception from the job EXECUTE METHOD

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

8.

How Do You Update The Jobdatamap Between Execution Of Jobs?

Answer»

USE the PersistJobDataAfterExecution ANNOTATION to update the data in JobDataMap after the JOB executes SUCCESSFULLY.

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

9.

How Do You Handle Or Prevent Concurrent Execution Of Jobs?

Answer»

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.

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.

10.

How Do You Store Job State?

Answer»

The JOBDATAMAP is USED to store STATE that will be PROVIDED to the job when it executes.

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

11.

How Is The Crontrigger Used?

Answer»

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.

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.

12.

How Do I Customize Thread Management?

Answer»

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.

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.

13.

How Is The Simpletrigger Used?

Answer»

A SIMPLETRIGGER is used for a SINGLE execution or an execution that REPEATED a specific number of times over a given interval.

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

14.

How Do I Check The Status Of A Running Job?

Answer»

The JobListener will allow you to check the STATUS of a running JOB.

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

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

15.

How Do You Begin A Quartz Process So That It Will Start Executing Jobs?

Answer»

To begin a quartz process you must initiate all the components, scheduler, JOB and trigger, and then call the START method on the scheduler.

  1. Trigger trigger = TriggerBuilder.newTrigger().withIdentity("jcgTriggerName", "group1")
  2. .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?")).build();
  3. Scheduler scheduler;
  4. scheduler = NEW StdSchedulerFactory().getScheduler();
  5. scheduler.start();
  6. JobKey jobKey = new JobKey("jcgJobName", "group1");
  7. JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity(jobKey).build();
  8. scheduler.scheduleJob(job, trigger);

To begin a quartz process you must initiate all the components, scheduler, job and trigger, and then call the start method on the scheduler.

16.

What Are The Three Key Components To Consider When Using Java Quartz?

Answer»

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.

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.