Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
More About Simple Trigger 
 

Simple trigger can be used to one shot execution or fire a job and in other words, we can say that just a single execution of job to the specified time.

 

More About Simple Trigger

                         

Simple trigger can be used to one shot execution or fire a job and in other words, we can say that just a single execution of job to the specified time. Sometimes, we wish to execute or fire a job at the specified time that has till 'N' repetition times with delay between 'T' executions of jobs that means if you need to have a job execute exactly once at a specific time, or at a specific moment in time that is followed by repeats at a specified time interval.

The SimpleTrigger properties contains: a start-time and end-time, a repeat count and a repeat interval. The repeat count properties can be zero, a positive integer or the constant value SimpleTrigger.REPEAT_INDEFINITELY. The repeat interval property must be zero or a positive long value that represents a number of milliseconds. The end-time property over-rides the repeat count property that can be used for creating a trigger which fires every some specified time (20 seconds). It has to compute the number of times that would be repeated between the start-time and end-time, if we want to specify the end-time then we can use a repeat count of REPEAT_INDEFINITELY.

We are going to implement a SimpleTrigger constructor to following types:

public SimpleTrigger(String name, String group, Date startTime, Date endTime, int repeatCount, long repeatInterval);
     
This is the constructor of java.org.quartz.SimpleTrigger class. Which fires or executes at the specified time and repeat at the specified number of times. It takes following arguments like this:

            name: This is the name of Simple Trigger.
            group:
This is the name of scheduler group.
            startTime: 
This is the time for firing or executing the Trigger.
            endTime:
This is the time for the Trigger to drop repeat firing or executing. 
            repeatCount:
This is the number of repeat firing or executing the Trigger by using the REPEAT_INDEFINITELY  for no any foundation of time.
            repeatInterval:
This is the time (milliseconds) for stopping or pausing the repeat firing.

There are following examples for implementing the SimpleTrigger:

1. Example SimpleTrigger : Create a simple trigger which fires exactly once, 20 seconds from now:

long startTime = System.currentTimeMillis() + (20L*1000L);

SimpleTrigger strigger  =  new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, new Date(startTime), null, 0, 0L);

2. Example SimpleTrigger : Create a simple trigger that fires quickly and repeats every 20 seconds:

SimpleTrigger strigger  =  new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, 20L * 1000L);

3. Example SimpleTrigger: Create a Simple Trigger that fires quickly and repeats every 10 seconds until 50 seconds from now:

long endTime = System.currentTimeMillis() + (50L * 1000L);

SimpleTrigger strigger  =  new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, new Date(), new Date(endTime), SimpleTrigger.REPEAT_INDEFINITELY, 10L * 1000L);

4. Example SimpleTrigger: Create a Simple Trigger that fires on February 19 of the year 2007 at accurately 9:15 am, and repeats 10 times with 20 seconds delay between each firing.

java.util.Calendar cal = new java.util.GregorianCalendar(2007,cal.FEB, 19);
cal.set(cal.HOUR, 9);
cal.set(cal.MINUTE, 15);
cal.set(cal.SECOND, 0);
cal.set(cal.MILLISECOND, 0);

Data startTime = cal.getTime();

SimpleTrigger trigger = new SimpleTrigger("mySimpleTrigger", sched.DEFAULT_GROUP, startTime, 10, 20L*1000L);

Simple Trigger Misfire Instructions

When the misfire instruction occurs then what should to do the Quartz. There are following misfire instructions to use for informing the Quartz.

    MISFIRE_INSTRUCTION_FIRE_NOW

     MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT

   MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT

   MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT

   MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_EXISTING_COUNT

Here is the also mis-fire instruction that have used for all trigger types:

   Trigger.MISFIRE_INSTRUCTION_SMART_POLICY

When we will use the "smart policy" misfire instruction with the triggers then the SimpleTrigger determine between its various types of mis-fire instructions that depends upon the configuration and state of the specified SimpleTrigger instance. The JavaDOC has the SimpleTrigger.updateAfterMisfire() method that describes the brief description of this dynamic behavior.

                         

» View all related tutorials
Related Tags: c ide list interface script object io ip vi factory trigger instance int this id ai job shutdown if example

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.