Announcement Announcement Module
Collapse
No announcement yet.
Multiple Quartz SchedulerFactoryBean instances Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Quartz SchedulerFactoryBean instances

    Hi,

    I need to have two SchedulerFactoryBeans in my application because one should be responsible for DB persisted jobs and the other one for memory
    persisted jobs.

    I tried to just create two of those beans but no matter what I do, only
    one of them is actually executing any job.

    Is this a limitation of Spring/Quartz or should this be possible?

    thanks

  • #2
    I normally use different schedulers so schedulers are completely isolated. This should not be a problem.

    Can you place both task in scheduler1 and see of both tasks work? And can you place both task in scheduler2 and check if they work?

    Comment


    • #3
      thx for your reply...

      what do you mean by different schedulers?

      what I have is two bean definitions like:

      Code:
      	<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
      		<property name="autoStartup">
      			<value>true</value>
      		</property>
      
      		<property name="applicationContextSchedulerContextKey">
      			<value>applicationContext</value>
      		</property>
      
      		<property name="overwriteExistingJobs">
      			<value>true</value>
      		</property>
      
      		<property name="waitForJobsToCompleteOnShutdown">
      			<value>true</value>
      		</property>
      
      		<property name="dataSource">
      			<ref local="dataSource" />
      		</property>
      
      		<property name="quartzProperties">
      			<props>
      				<!-- ThreadPool -->
      				<prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
      				<prop key="org.quartz.threadPool.threadCount">1</prop>
      				<prop key="org.quartz.threadPool.threadPriority">5</prop>
      
      				<!-- Job store -->
      				<!-- see: http://www.opensymphony.com/quartz/wikidocs/ConfigJobStoreTX.html -->
      				<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
      				<prop key="org.quartz.jobStore.isClustered">true</prop>
      				<prop key="org.quartz.jobStore.clusterCheckinInterval">60000</prop>
      				<prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
      				<prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
      				<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
      				<prop key="org.quartz.jobStore.driverDelegateClass">
      					org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
      				</prop>
      				<prop key="org.quartz.jobStore.useProperties">false</prop>
      				<prop key="org.quartz.jobStore.selectWithLockSQL">
      					SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?
      				</prop>
      			</props>
      		</property>
      		
      		<property name="triggers">
      			<list>
      
      bla bla bla
      and from the logs and outcome, I can see that only one of those beans is actually "started".

      Comment


      • #4
        set the property 'schedulerName' in each definition
        Code:
        <bean id="RAMScheduler"
            class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
            lazy-init="false">    <property name="schedulerName" value="RAMScheduler"/>
        ....

        Comment


        • #5
          WOW,

          many thanks,
          seems like that did the trick...

          did you get this information from the docs?
          I couldn't find something related.

          thanks

          Comment


          • #6
            Question on this post: why is it necessary to set the schedulerName property? Why can't the id value of the bean differentiate the bean's identity? This caused me an hour of monitor head banging and several searches in forums to figure this out. This is one of several 'small things' that annoy me when working with Spring.

            Comment


            • #7
              schedulerName uniqueness reason

              Dan_Abq, we hit an issue with the same root cause.

              The "job executor" is actually not the SchedulerFactoryBean. It is the Scheduler bean(to be precise calling its start method invokes the aggregated QuartzScheduler.start method which fires the Trigger-s), provided by the SchedulerFactoryBean. As a matter of fact this Scheduler is stored(and looked-up) under the schedulerName(which if not explicitly set has the same default value for every configured SchedulerFactoryBean) in the SchedulerRepository singleton(SchedulerRepository.getInstance()).

              That's how unless you set a different schedulerName for your SchedulerFactoryBean-s, you will always get the same scheduler by each and every SchedulerFactoryBean-s

              Comment

              Working...
              X