Doing Scheduled agents When not on a Domino server

When you step outside the warmth and comfort of a domino server a lot of things frighten the willies out of you, things you took for granted are suddenly not there, so i thought each time i have to do a notes equivalent in the cold hard
world, I would share:

Today sprig of joy is scheduled agents in Java (on a JBoss server actually), this is all supplied thanks to the amazing people over at http://www.opensymphony.com/quartz/, its far more powerful than my example, but it easy to understand when you come from notes, and you can expand on it as you see fit (instruction are in the comments), have fun (oh, if the code looks cramped just copy it to a bigger text widow as i left all the proper indenting in)

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;
public class JustLikeANotesAgent {
    public static void SetUpNotesTypeAgent(String CronTriggerPram) throws 
Exception {
        // setting up the scheduler which is basically the equivalent of agent 
manager
       Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        // setting up our "Agent" ie giving it a name and linking it to a chunk 
of code
        JobDetail NotesAgent = new JobDetail("NotesAgentName", null, 
AgentCode.class);
        // setting up our schedule ,there are "simple triggers" and 
"Crontriggers"
        // Crontriggers are more powerful and easy to get a handle on if your 
used to notes
        CronTrigger AgentSchedule=new CronTrigger("AgentScheduleName",null
,CronTriggerPram);
        // linking the Agent to its schedule and "enabling" it
        scheduler.scheduleJob(NotesAgentName, AgentScheduleName);
        scheduler.start(); // and off we go, basically "load Agmr"
    }
    public static void main(String[] args) {
           //the following string is a Cron Trigger that runs every 5 mins
           // tutorial on crontriggers can be found HERE
     String CronTriggerPram = "0 0/5 * * * ?";
     try {
      SetUpNotesTypeAgent(CronTriggerPram);
     } catch (Exception e) {
      e.printStackTrace();
     } 
            //scheduler.shutdown(); this is commented out as its basically like 
"tell agmr quit"     
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *