Results 1 to 5 of 5

Thread: quartz in cluster with same instanceId

  1. #1
    Join Date
    Feb 2005
    Posts
    2

    Default quartz in cluster with same instanceId

    My problem is as follows:

    I have a service method doIt() which simply puts a message on a JMS queue for each user having a certain property X, which is determined via a dB lookup. doIt() is called at a regular intervals.

    To achieve this aim in a non-cluster I just use MethodInvokingJobDetailFactoryBean with a cronTrigger and RAMJobStore and all is fine.

    When moving to a cluster and using JobStoreTX I have the following issues: (1) JobDetails created by MethodInvokingJobDetailFactoryBean are non-serializable; (2) no way to have each instance in cluster have same instanceId such that only one cluster succeeds in sending the message -- dB corruption issues aplenty.

    (1) is solvable by writing my own Job, but (2) is more problematic. Playing around with the quartz examples in their downloadable I realised that clustering support is there to support fail-over, not what I'm wanting to do.

    To solve (2) I was thinking of writing a line in doIt() like

    Code:
    if (aquireDbLock()) { 
       // ... do Work  
    } 
    // else do nothing as assume other cluster got there first
    but writing aquireDbLock() involves setting up a custom lock table etc that will involve its own issues/maintainance moving forward.

    Is there a way of using quartz or some other technology to achieve my aim? One way is just not to deploy the code to the cluster, just one box instead but (a) boss man doesn't like that cause it'll involve a seperate release procedure ; and (b) no fail-over support in that solution.

    Cheers,

    Anthony.

  2. #2

    Default

    What is the DB you are using?

    If Oracle, I do 'select ... for update NOWAIT' to lock all rows with property x and some other field which will be updated once the the message is successfully put on the queue. That way, only one server instance in the cluster can process the job at one time. You would not need to maintain a lock table for that solution.
    J2EEGuru,
    The Spring Advocate

  3. #3
    Join Date
    Feb 2005
    Posts
    2

    Default

    I am using Oracle 10g, so yes the select for update clause to lock rows in some mutex lock table would work.

    Another alternative maybe that since we are using Weblogic 8.1 as the app server if I package this as a separate ear then might be able to target only to one cluster in some weblogic xml config in order to avoid any special release script.

    Mainly wanted to sanity check myself in the sense no sort of quartz configuration solves this problem. Would be good to read any quartz guys thoughts on this.

  4. #4
    Join Date
    Nov 2007
    Posts
    1

    Default

    Well, what you seem to be looking for is Stateful Jobs. Stateful jobs will never be executed at the same time even in a clusterized quartz deployment. Note that the ending state of the job is not mandatory. We uses it and it works perfectly.

  5. #5
    Join Date
    Mar 2009
    Posts
    1

    Default

    Quote Originally Posted by juldsc View Post
    Well, what you seem to be looking for is Stateful Jobs. Stateful jobs will never be executed at the same time even in a clusterized quartz deployment. Note that the ending state of the job is not mandatory. We uses it and it works perfectly.
    Is this true when using a cluster of WebLogic nodes (i.e., when not clustering Quartz alone)?

Similar Threads

  1. Runtime managing Quartz jobs in cluster?
    By vmarcinko in forum Container
    Replies: 1
    Last Post: Oct 20th, 2011, 10:06 AM
  2. Migrating to new version of Quartz
    By ramkris in forum Container
    Replies: 4
    Last Post: Nov 15th, 2005, 02:51 AM
  3. Quartz question
    By kuns in forum Container
    Replies: 3
    Last Post: Jul 11th, 2005, 03:03 PM
  4. Quartz - Couldn't retrieve job
    By newreaders in forum Container
    Replies: 4
    Last Post: Jun 1st, 2005, 08:12 PM
  5. broadcast application events across a cluster?
    By ctassoni in forum Architecture
    Replies: 3
    Last Post: Feb 22nd, 2005, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •