Learn Scheduling using Quartz

Posted on by By Nikhilesh, in Business Intelligence | 0

Why do we need scheduling?
Scheduling is needed if you want to automate the repetition of a task at specific intervals or        particular date. You could of course manually watch the time and execute your task, albeit an inefficient task. If anyone wants to do particular task after every 3 seconds, then who wants to watch the computer every 3 seconds just to hit the Enter key? No one.

History of the Quartz Framework

Quartz was created by James House, who envisioned the first conceptual pieces of the framework in 1998. These included the concept of a queue of jobs and a pool of threads to process the jobs, although probably in an unrecognizable form by most of today’s Quartz users.



Before you can use the scheduler, it needs to be instantiated. To do this, you use a SchedulerFactory. Some users of Quartz may keep an instance of a factory in a JNDI store, others may find it just as easy (or easier) to instantiate and use a factory instance directly (such as in the example below).

Once a scheduler is instantiated, it can be started, placed in stand-by mode, and shutdown. Note that once a scheduler is shutdown, it cannot be restarted without being re-instantiated. Triggers do not fire (jobs do not execute) until the scheduler has been started, nor while it is in the paused state.

Here’s a quick snippet of code, that instantiates and starts a scheduler, and schedules a job for execution:

SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();


Scheduler sched = schedFact.getScheduler();







// define the job and tie it to our HelloJob class

JobDetail job = newJob(HelloJob.class)

.withIdentity(“myJob”, “group1”)





// Trigger the job to run now, and then every 40 seconds

Trigger trigger = newTrigger()

.withIdentity(“myTrigger”, “group1”)







// Tell quartz to schedule the job using our trigger

sched.scheduleJob(job, trigger);



By Prashansa Kumari

Helical IT Solutions


Best Open Source Business Intelligence Software Helical Insight is Here


A Business Intelligence Framework

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments