views:

295

answers:

3

Hi,

I have a building block which sets up a Quartz job to send out emails every morning. The job is fired three times every morning instead of once. We have a hosted instance of Blackboard, which I am told runs on three virtual servers. I am guessing this is what is causing the problem, as the building block was previously working fine on a single server installation.

Does anyone have Quartz experience, or could suggest how one might prevent the job from firing multiple times?

Thanks,

A: 

You didn't describe in detail how your Quartz instance(s) are being instantiated and started, but be aware that undefined behavior will result if you run multiple Quartz instances against the same job store database at the same time, unless you enable clustering (see http://www.quartz-scheduler.org/docs/configuration/ConfigJDBCJobStoreClustering.html).

Will
A: 

Hi, The original question was posted on my behalf by GustlyWind.

I'm just using

org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore 

in this case. Do you think I will need to use a database for the job store in order to get clustering working?

The Quartz instance is initiated as follows in the web application's web.xml file:

    <servlet> 
  <servlet-name>QuartzInitializer</servlet-name> 
  <display-name>Quartz Initializer Servlet</display-name> 

  <servlet-class>
    org.quartz.ee.servlet.QuartzInitializerServlet
  </servlet-class> 

  <load-on-startup>1</load-on-startup>

  <init-param>
    <param-name>config-file</param-name>
    <param-value>my_quartz.properties</param-value>
  </init-param>

  <init-param>
    <param-name>shutdown-on-unload</param-name>
    <param-value>true</param-value>
  </init-param>

  <init-param>
    <param-name>start-scheduler-on-load</param-name>
    <param-value>true</param-value>
  </init-param>
 </servlet> 

Thanks, Mike

Mike
A: 

I guess I'm a little late responding to this, but we have a similar sort of scenario with our application. We have 4 servers running jobs, some of which can run on multiple servers concurrently, and some should only be run once. As Will's response said, you can look into the clustering features of Quartz.

Our approach was a bit different, as we had a home-grown solution in place before we switched to Quartz. Our jobs utilize a database table that store the cron triggers and other job information, and then "lock" the entry for a job so that none of the other servers can execute it. This keeps jobs from running multiple-times on the servers, and has been fairly effective so far.

Hope that helps.

MattGWagner