Announcement Announcement Module
Collapse
No announcement yet.
Quartz jobs are executed simultaniously in a cluster environment Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz jobs are executed simultaniously in a cluster environment

    Hi,
    I'm working with spring 3.1.2.RELEASE, quartz 1.8.6, MSSQL server and tomcat 7.x.
    I'm trying to run a simple task in a cluster of two tomcat nodes, and quartz seems to execute the job on both nodes simultaniously. I have a simple job which is scheduled to run every 10 seconds. I expect, that in a cluster environment, within any given interval of 10 seconds quartz is supposed to run the job only once, regardless of the node it chooses to execute the job. The actual behaviour I see is that the task is executed on both nodes, where the difference between one node's execution and another is much less than 10 seconds.

    Below is the following spring context I use:
    ...
    <context:component-scan base-package="org.samples.schedule" />

    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ref="scheduleDataSource" />
    </bean>

    <jee:jndi-lookup id="scheduleDataSource" jndi-name="jdbc/ScheduleDataSource" />

    <context:annotation-config />

    <bean class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="dataSource" ref="scheduleDataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="applicationContextSchedulerContextKey">
    <value>schedulerSample</value>
    </property>
    <property name="triggers">
    <list>
    <ref bean="simpleTrigger" />
    </list>
    </property>
    <property name="overwriteExistingJobs" value="true" />
    <property name="quartzProperties">
    <props>
    <prop key="org.quartz.scheduler.instanceName">Scheduler</prop>
    <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
    <prop key="org.quartz.jobStore.misfireThreshold">1000</prop>
    <prop key="org.quartz.jobStore.clusterCheckinInterval">1 000</prop>
    <prop key="org.quartz.jobStore.class">
    org.quartz.impl.jdbcjobstore.JobStoreTX
    </prop>
    <prop key="org.quartz.jobStore.driverDelegateClass">org. quartz.impl.jdbcjobstore.MSSQLDelegate
    </prop>
    <prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
    <prop key="org.quartz.jobStore.isClustered">true</prop>
    <prop key="org.quartz.threadPool.class">
    org.quartz.simpl.SimpleThreadPool
    </prop>
    <prop key="org.quartz.threadPool.threadCount">10</prop>
    <prop key="org.quartz.threadPool.threadPriority">5</prop>
    </props>
    </property>
    </bean>

    <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <!-- see the example of method invoking job above -->
    <property name="jobDetail" ref="loggerJob" />
    <property name="repeatInterval" value="10000" />
    </bean>

    <bean name="loggerJob" class="org.springframework.scheduling.quartz.JobDe tailBean">
    <property name="jobClass" value="org.samples.schedule.BatchJobWrapper" />
    <property name="jobDataAsMap">
    <map>
    <entry key="jobName" value="logTask" />
    </map>
    </property>
    </bean>
    </beans>

    I simply deploy the same application on two tomcat instances and start the both.
    Any ideas?

    Thanks,
    jacobo

  • #2
    Same behaviour is observed when using org.springframework.scheduling.quartz.CronTriggerB ean instead of a simple org.springframework.scheduling.quartz.SimpleTrigge rBean:

    <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.CronT riggerBean">
    <property name="jobDetail" ref="loggerJob" />
    <property name="cronExpression" value="0/10 * * * * ?" />
    </bean>

    Tasks just get executed on both nodes same time...

    Regards,
    jacobo.
    Last edited by jacobo; Nov 19th, 2012, 03:23 AM.

    Comment


    • #3
      This isn't a batch question but a Quartz question...moving to Core Spring forum.

      Comment

      Working...
      X