Did this blog help you solve a problem? Tip me with Bitcoins at: 17dQktcAmU4urXz7tGk2sbuiCqykm3WLs6

Monday, September 13, 2010

Java Quartz - Disable Update Check

I noticed that when my applications start up which use the Quartz job scheduling api, Quartz was pinging www.terracotta.org to see if there were any updates available. The check was also throwing an error:

Quartz version update check failed: java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.terracotta.org/kit/reflector?kitID=quartz&pageID=update.properties&id=-1062731163&os-name=Mac+OS+X&jvm-name=Java+HotSpot%28TM%29+Client+VM&jvm-version=1.5.0_24&platform=i386&tc-version=1.8.3&tc-product=Quartz&source=Quartz&uptime-secs=1&patch=UNKNOWN

The following code snippet shows how to prevent Quartz from doing an update check on startup. This works for sure with Quartz version 1.8.3.

In quartz.properties, add the following line:

org.quartz.scheduler.skipUpdateCheck = true




Piece of Cake!!!

Friday, September 10, 2010

Quartz Jobs.xml Example - Adding a Durable Job

The following sample XML shows how to set up a single Quartz job without a trigger in a jobs.xml configuration file. I first tried just creating a job without any trigger associated with it, but I got a runtime error:

Error scheduling jobs: A new job defined without any triggers must be durable...A new job defined without any triggers must be durable...

The following scheduled job is called SampleJob. The one tricky catch is that in order to set the job as durable, you also have to include the volatility AND recover elements. This works for sure with Quartz version 1.8.3.

<?xml version='1.0' encoding='utf-8'?>
<job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
  version="1.8">

    <schedule>
        <job>  
            <name>SampleJob</name>
            <group>DEFAULT</group>
            <job-class>com.xyz.SampleJob</job-class>
            <volatility>false</volatility> 
            <durability>true</durability> 
            <recover>false</recover> 
            <job-data-map>
                <entry>
                    <key>Param1</key>
                    <value>N</value>
                </entry>
            </job-data-map>
        </job>            
    </schedule>
</job-scheduling-data>



Piece of Cake!!!