Hire Me

Friend’s Blogs:

Partners Blogs:

Stuff:

Doing Scheduled agents When not on a Domino server

July 10th, 2009

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)

importorg.quartz.CronTrigger;importorg.quartz.JobDetail;importorg.quartz.Scheduler;importorg.quartz.impl.StdSchedulerFactory;publicclassJustLikeANotesAgent{publicstaticvoidSetUpNotesTypeAgent(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"}publicstaticvoidmain(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"}}