Announcement Announcement Module
Collapse
No announcement yet.
Quarts Scheduler Problems (again) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quarts Scheduler Problems (again)

    Hi, I`m currently using 2 schedulers (each scheduler needs his own configuration settings so a single scheduler won`t do) and I`m getting strange results again. If a single job in the first scheduler takes a long time (I`m writing 100.000 records from the database in a searchengine) it seems the second scheduler never fires a job again -> my system totally stalls.

    I know there are no concurrency related problems and I have the feeling (this isn`t the first time I have had this problem) that the Schedulers are not completely independant. That some state is shared.. maybe one scheduler is waiting for a (internal scheduler) resource that is in use with the other scheduler. If this is the case, a deadlock could be the result.

    So.. has anyone had this problem before? Or know if there is (or isn`t) a relation between multiple scheduler instances?

    This is a part of the configuration:
    Code:
    <bean id="indexWriterJobCronTrigger"
    		class="org.springframework.scheduling.quartz.CronTriggerBean">
    
    		<property name="jobDetail">
    			<bean class="com.jph.spring.MethodInvokingSequenceJobDetailFactoryBean">
    				<property name="methodInvokerList">
    					<list>
    						<bean class="org.springframework.util.MethodInvoker">
    							<property name="targetObject" ref="indexUpdater"/>
    							<property name="targetMethod" value="process"/>
    						</bean>
    
    						<bean class="org.springframework.util.MethodInvoker">
    							<property name="targetObject" ref="indexOptimizer"/>
    							<property name="targetMethod" value="optimize"/>
    						</bean>
    
    						<bean class="org.springframework.util.MethodInvoker">
    							<property name="targetObject" ref="indexReaderProviderService"/>
    							<property name="targetMethod" value="refresh"/>
    						</bean>
    					</list>
    				</property>
    
    				<property name="concurrent" value="false"/>
    			</bean>
    		</property>
    
    		<property name="cronExpression">
    			<!-- iedere minuut -->
    			<value>0 0/1 * * * ?</value>
    		</property>
    	</bean>
    
    
    	<bean id="indexchangeScheduler"
    		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    
    		<property name="applicationContextSchedulerContextKey">
    			<value>indexchangeScheduler</value>
    		</property>
    
    		<property name="quartzProperties">
    			<props>
    				<prop key="org.quartz.threadPool.class">
     					org.quartz.simpl.SimpleThreadPool
    				</prop>
    				<!--
    					- om te verhinderen dat er meerdere indexatie-taken verlopen,
    					- moet er maar 1 thread in de pool zitten.
    					-->
    				<prop key="org.quartz.threadPool.threadCount">1</prop>
    				<prop key="org.quartz.threadPool.threadPriority">5</prop>
    
    				<prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
    				<!--prop key="org.quartz.jobStore.misfireThreshold">0</prop -->
    
    				<prop key="org.quartz.plugin.triggHistory.class">
    					org.quartz.plugins.history.LoggingTriggerHistoryPlugin
    				</prop>
    
    				<prop key="org.quartz.plugin.triggHistory.triggerFiredMessage">
    					Trigger &#123;1&#125;.&#123;0&#125; fired job &#123;6&#125;.&#123;5&#125; at&#58; &#123;4,date, HH&#58;mm&#58;ss MM/dd/yyyy&#125;
    				</prop>
    
    				<prop key="org.quartz.plugin.triggHistory.triggerCompleteMessage">
    					Trigger &#123;1&#125;.&#123;0&#125; completed firing job&#123;6&#125;.&#123;5&#125; at &#123;4, date, HH&#58;mm&#58;ss MM/dd/yyyy&#125; with resulting trigger instruction code&#58; &#123;9&#125;
    				</prop>
    			</props>
    		</property>
    
    		<property name="triggers">
    			<list>
    				<ref bean="indexWriterJobCronTrigger"/>
    			</list>
    		</property>
    	</bean>
    
    
    	<!--
    	 	- De crawlScheduler is verantwoordelijk voor het schedulen van alle crawlers
    		-->
    	<bean id="crawlScheduler"
    		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    
    		<property name="applicationContextSchedulerContextKey" value="scanScheduler"/>
    
    		<property name="quartzProperties">
    			<props>
    				<prop key="org.quartz.threadPool.class">
    						 org.quartz.simpl.SimpleThreadPool
    				</prop>
    				<prop key="org.quartz.threadPool.threadCount">4</prop>
    				<prop key="org.quartz.threadPool.threadPriority">1</prop>
    
    				<prop key="org.quartz.plugin.triggHistory.class">
    						org.quartz.plugins.history.LoggingTriggerHistoryPlugin
    				</prop>
    
    				<prop key="org.quartz.plugin.triggHistory.triggerFiredMessage">
    						Trigger &#123;1&#125;.&#123;0&#125; fired job &#123;6&#125;.&#123;5&#125; at&#58; &#123;4,date, HH&#58;mm&#58;ss MM/dd/yyyy&#125;
    				</prop>
    
    				<prop key="org.quartz.plugin.triggHistory.triggerCompleteMessage">
    						Trigger &#123;1&#125;.&#123;0&#125; completed firing job&#123;6&#125;.&#123;5&#125; at &#123;4, date, HH&#58;mm&#58;ss MM/dd/yyyy&#125; with resulting trigger instruction code&#58; &#123;9&#125;
    				</prop>
    			</props>
    		</property>
    
    		<property name="triggers">
    			<list>
    				<ref bean="bedrijfCrawlerIaw_JobCronTrigger"/>
    				<ref bean="bedrijfCrawlerOg_JobCronTrigger"/>
    				<ref bean="bedrijfCrawlerGebi_JobCronTrigger"/>
    				<ref bean="bedrijfCrawlerBeni_JobCronTrigger"/>
    			</list>
    		</property>
    	</bean>
    Btw:
    I was planning to kick out quartz from our projects and make use of the ScheduledThreadPoolExecutor from the new jdk5.0 library. This is a good chance to do so..

  • #2
    I have removed one scheduler and replaced it with the ScheduledThreadPoolExecutorFactoryBean and the system works as it should. So Quartz or the Spring integration can cause a deadlock because the Schedulers are not independant.

    This is the Spring configuration for the ScheduledThreadPoolExecutorFactoryBean:
    Code:
    <bean id="indexUpdaterScheduler"
    		  class="org.jph.spring.scheduling.concurrent.ScheduledThreadPoolExecutorFactoryBean">
    
    		<property name="scheduledWithFixedDelayRunnable">
    			<bean class="org.jph.spring.scheduling.concurrent.ScheduledWithFixedDelayRunnable">
    				<property name="runnable">
    					<bean class="org.jph.spring.scheduling.MethodInvokeSequenceRunnable">
    						<property name="methodInvokerList">
    							<list>
    								<bean class="org.springframework.util.MethodInvoker">
    									<property name="targetObject" ref="indexUpdater"/>
    									<property name="targetMethod" value="process"/>
    								</bean>
    
    								<bean class="org.springframework.util.MethodInvoker">
    									<property name="targetObject" ref="indexOptimizer"/>
    									<property name="targetMethod" value="optimize"/>
    								</bean>
    
    								<bean class="org.springframework.util.MethodInvoker">
    									<property name="targetObject" ref="indexReaderProviderService"/>
    									<property name="targetMethod" value="refresh"/>
    								</bean>
    							</list>
    						</property>
    					</bean>
    				</property>
    				<property name="initialDelay" value="6000"/>
    				<property name="delay" value="60000"/>
    				<property name="timeUnit" ref="java.util.concurrent.TimeUnit.MILLISECONDS"/>
    			</bean>
    		</property>
    	</bean>
    I hope this functionality will be added to the Spring core (I have made a feature request) But if someone wants to use it, you can email me to get the code.

    Comment

    Working...
    X