2013-09-30 25 views
0

我看到了各種線程在timertask問題。不過,我想要澄清一下Spring Scheduler API(3.1)的內部工作。春季實施 - 循環計時器

我有要求每10秒啓動一個計時器。該應用程序在羣集的websphere zos中運行。 (至少4個jvm節點)。

這是接線。

<bean id="dataProcessSchedulerTask" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean"> 
    <property name="targetObject" ref="ondataTransferTimerWakeupService" /> 
    <property name="targetMethod" value="processDataFeedMetadata" /> 
</bean> 

<bean id="DATA_PROCESS_TIMER" 
    class="org.springframework.scheduling.timer.ScheduledTimerTask"> 
    <property name="timerTask" ref="DATAProcessSchedulerTask" /> 
    <property name="delay" value="#{systemProperties.DATA_PROCESS_TIMER}" /> 
    <property name="period" value="#{systemProperties.DATA_PROCESS_TIMER}" /> 
</bean> 

<bean class="org.springframework.scheduling.timer.TimerFactoryBean"> 
    <property name="scheduledTimerTasks"> 
    list> 
     <ref bean="DATA_PROCESS_TIMER" /> 
    </list> 
    </property> 
</bean> 
<bean id="onDATATransferTimerWakeupService" class="com.serviceimpl.OnDATATransferTimerWakeupService" /> 

我已經爲processDataFeedMetadata方法定義了(@async)。

問題我看到定時器每10秒正確啓動一次(4 jvms - 每24分鐘發生一次定時器),在幾小時後開始行爲異常(2或3 jvms停止發射任何定時器 - 6到每分鐘發生12次計時)。我瞭解timertask的實現有其自身的侷限性。但是,如果我從MethodInvokingTimerTaskFactoryBean調用一個ASYNC方法,那麼爲什麼timertask會在調用ASYNC方法時立即在該時間間隔內完成並且行爲不當。 (2)我沒有看到任何應用程序日誌的異常,並且MethodInvokingTimerTaskFactoryBean應該處理並消耗任何異常(如果有)。

真的很感謝,如果有人對這裏發生的事情有什麼意見嗎?

回答

0

你有這個問題,1個JVM?