Learn Scheduling using Quartz

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.

 

QUARTZ:-

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();

 

sched.start();

 

 

 

 

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

JobDetail job = newJob(HelloJob.class)

.withIdentity(“myJob”, “group1”)

.build();

 

 

 

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

Trigger trigger = newTrigger()

.withIdentity(“myTrigger”, “group1”)

.startNow()

.withSchedule(simpleSchedule()

.withIntervalInSeconds(40)

.repeatForever())

.build();

 

// Tell quartz to schedule the job using our trigger

sched.scheduleJob(job, trigger);

 

 

By Prashansa Kumari

Helical IT Solutions

Jaspersoft Report Scheduler

This blog will talk about how to use Jaspersoft Report Scheduler, its configuration etc.

1.       Report Scheduler  :  It is an automated and iterative platform to email reports to anyone in PDF,CSV,Excel,….etc format.

 

2.       To  send email , it should be connected to outbound email server,  so for this it should be configured accordingly

a.       Go  to this  path : C:\Jaspersoft\jasperreports-server-5.5\apache-tomcat\webapps\jasperserver-pro\WEB-INF\js.quartz.properties

 

You will find the js.quartz.properties file like below screenshot:

Jaspersoft Report Scheduler 1

b.Change the yellow mark values to your required input

c.Restart the Jasper Server

 

3. Now Go to Report Wizard and scheduled your required job or report :

 

Below mentioned are the steps to be followed for doing the same:

Jaspersoft Report Scheduler 2

b. After this go to “create schedule “ tab , you will find like this:

Jaspersoft Report Scheduler 3

Here you can set how frequently you want to schedule this report and for what timezone

c. Then go for the “output options” tab in this window only[in the 2nd right] Here you have to specify in what format you want to send the report

Jaspersoft Report Scheduler 4d. Then go for “notification” in this window. To whom all we want to send the reports, the same is to be specified in this window

Jaspersoft Report Scheduler 5

Now You have successfully scheduled the reports…!!!

4. If we want to stop the scheduler, then go to this location

C:\Jaspersoft\jasperreports-server-5.5\apache-tomcat\webapps\jasperserver-pro\WEB-INF\applicationContext-report-scheduling.xml

Jaspersoft Report Scheduler 6

Remove the init-method=”start”

Restart the Jasperserver

Thanks

Rupam

Helical IT Solutions