{"id":242,"date":"2005-03-03T15:31:35","date_gmt":"2005-03-03T21:31:35","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=242"},"modified":"2005-03-03T15:31:35","modified_gmt":"2005-03-03T21:31:35","slug":"quartz-and-java-job-scheduling","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/242","title":{"rendered":"Quartz and java job scheduling"},"content":{"rendered":"<p>I&#8217;m working on a stand alone java application that needs some fairly sophisticated scheduling capabilities, more than <a href='http:\/\/java.sun.com\/j2se\/1.5.0\/docs\/api\/java\/util\/Timer.html\n'>java.util.Timer<\/a> can provide.  Normally, I&#8217;d reach for trusty old <a href='http:\/\/www.rt.com\/man\/cron.8.html'>cron<\/a>, but in this case, it&#8217;s a java program that needs to be run on both unix and windows with a minimum of fuss.  <\/p>\n<p><a href='http:\/\/www.opensymphony.com\/quartz'>Quartz<\/a> to the rescue.  This open source java package lets you schedule a myriad of executable objects in many different ways.  There are many different ways to use Quartz; there&#8217;s a nice <a href='http:\/\/www.opensymphony.com\/quartz\/tutorial.html'>tutorial<\/a> here, and the <a href='http:\/\/quartz.sourceforge.net\/javadoc\/'>Quartz javadoc<\/a> is pretty up to date.  <\/p>\n<p>All I&#8217;m using it for is a cross-platform cron replacement, but it does seem to have large number of other features.  The one that I&#8217;m not using that seems the most useful is the ability to differentiate between activities (a <a href='http:\/\/quartz.sourceforge.net\/javadoc\/org\/quartz\/Job.html'>Job<\/a>) to be scheduled, and the events, be they time or otherwise related, that should cause those activities to be executed (a <a href='http:\/\/quartz.sourceforge.net\/javadoc\/org\/quartz\/Trigger.html'>Trigger<\/a>).  Nice orthogonality, but for my purposes, overkill.  However, I can see the usefulness of this feature.<\/p>\n<p>The coolest feature that I <em>am<\/em> using is <a href='http:\/\/quartz.sourceforge.net\/javadoc\/org\/quartz\/JobExecutionContext.html#getScheduler()'>JobExecutionContext.getScheduler()<\/a> which allows any job running to access the scheduler in which they are running.  They can delete themselves, verify that other jobs are working, and even shutdown the scheduler.<\/p>\n<p>If you have to do scheduling in java, you should take a look at Quartz.  (Here is a <a href='http:\/\/www.onjava.com\/pub\/a\/onjava\/2004\/03\/10\/quartz.html?page=1'>survey of job scheduling options in Java<\/a>.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on a stand alone java application that needs some fairly sophisticated scheduling capabilities, more than java.util.Timer can provide. Normally, I&#8217;d reach for trusty old cron, but in this [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-242","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=242"}],"version-history":[{"count":0,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/242\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}