We saw that a class that implements the job interface is the actual job, now if you want to pass more information to the Quartz you would be using the JobDetail class.
Lets talk about the JobDetail in detail....
JobDetail jobDetail= new JobDetail("first job",sched.DEFAULT_GROUP,"firstjob.class");
Take a closer look at the snippet given above you 'll see that we are supplying the job with the detail of the job class. Everytime the scheduler executes the job creates new instances of the class calling its execute method.
Now lets get to know more about the Trigger's that are associated with each JOB. There are two types of triggers in Quartz :- SimpleTrigger and CronTrigger.
SimpleTrigger :-
You can use the Simple Trigger in cases where you want your job to execute exactly once or at a specific moment in time followed by repeats at specific intervals. Lets take a look at one;
SimpleTrigger trigger= new SimpleTrigger("firstTrigger", sched.DEFAULT_GROUP, new Date(),SimpleTrigger.REPEAT_INDEFINITELY,60L*1000L);
The constructor takes a start time and a end-time and the repeat interval. The repeat interval can be either 0 or a positive number or a constant
REPEAT_INDEFINITELY and repeats the number of milliseconds.Note that the end time property overrides the repeat count of the REPEAT_INDEFINITELY.
CronTrigger :-
You would go for Cron Trigger if you want your job to fire according to the calendar. You can set CronTriggers that fires every Friday at 12 pm or between 12 pm and 1pm.
CronExpressions are used to configure instances of the Trigger. A CronExpression is made of 6 sub-expressions they are -
# Seconds
# Minutes
# Hours
# Day-of-Month
# Month
#Day-of-Week
We can pass special characters like "0 0/5 ***?" this would means; creates a trigger that fires every 5 minutes.
"10 0/5 ***?" this would create a trigger that fires at 1.30,11.30....
You can get to know more about the Triggers and its expressions by reffering the doc files..
Well thats it for today... :)
Do correct me if I have made any mistakes and comments are most welcomed
Lets talk about the JobDetail in detail....
JobDetail jobDetail= new JobDetail("first job",sched.DEFAULT_GROUP,"firstjob.class");
Take a closer look at the snippet given above you 'll see that we are supplying the job with the detail of the job class. Everytime the scheduler executes the job creates new instances of the class calling its execute method.
Now lets get to know more about the Trigger's that are associated with each JOB. There are two types of triggers in Quartz :- SimpleTrigger and CronTrigger.
SimpleTrigger :-
You can use the Simple Trigger in cases where you want your job to execute exactly once or at a specific moment in time followed by repeats at specific intervals. Lets take a look at one;
SimpleTrigger trigger= new SimpleTrigger("firstTrigger", sched.DEFAULT_GROUP, new Date(),SimpleTrigger.REPEAT_INDEFINITELY,60L*1000L);
The constructor takes a start time and a end-time and the repeat interval. The repeat interval can be either 0 or a positive number or a constant
REPEAT_INDEFINITELY and repeats the number of milliseconds.Note that the end time property overrides the repeat count of the REPEAT_INDEFINITELY.
CronTrigger :-
You would go for Cron Trigger if you want your job to fire according to the calendar. You can set CronTriggers that fires every Friday at 12 pm or between 12 pm and 1pm.
CronExpressions are used to configure instances of the Trigger. A CronExpression is made of 6 sub-expressions they are -
# Seconds
# Minutes
# Hours
# Day-of-Month
# Month
#Day-of-Week
We can pass special characters like "0 0/5 ***?" this would means; creates a trigger that fires every 5 minutes.
"10 0/5 ***?" this would create a trigger that fires at 1.30,11.30....
You can get to know more about the Triggers and its expressions by reffering the doc files..
Well thats it for today... :)
Do correct me if I have made any mistakes and comments are most welcomed
No comments:
Post a Comment