0
在生產發佈的最後一分鐘,我發現Java Spring批處理存在一個奇怪的問題。它進入無限循環。Spring批處理作業無限循環
這裏是我的配置:
<batch:job id="dbasJob" restartable="true">
<batch:step id="dbasStep" next="webService">
<tasklet>
<chunk reader="campaignReader" processor="campaignProcessor" writer="campaignWriter" commit-interval="1"
skip-limit="50">
<skippable-exception-classes>
<include class="java.lang.Exception" />
</skippable-exception-classes>
<listeners>
<listener ref="campaignProcessListener" />
<listener ref="campaignSkipListener" />
</listeners>
</chunk>
</tasklet>
<batch:listeners>
<batch:listener ref="promotionListener" />
</batch:listeners>
</batch:step>
記錄總數是10,所以每次提交單一記錄進行操作後會發生。 我在寫入器中將結果寫入數據庫。
我從讀取器逐個讀取項目,處理並寫入數據庫。
public Campaign read()
{
return campaignList.isEmpty() ? null : campaignList.remove(0);
}
public Campaign process(Campaign campaign) throws UnexpectedInputException, ParseException, Exception {
try
public void write(List<? extends Campaign> campaignList) throws Exception
{//...Writing to DB...
它保持運行並無限地插入數據到表中。
觀察是:提交間隔<總記錄和跳過限制>提交間隔。
如果有人提出了一些解決方案/解決方法,對於我在生產版本因此問題持有的時間點對我的幫助最大。
非常感謝。
雖然是開放的這一個問題,你會發現,我們一直沒能重現此問題。如果你能提供一個能夠解決這個問題的測試案例,那麼這將對我們的工作產生很大的幫助。 –
感謝您的回覆。我已經看到了這個無限循環問題的開放票證,但實際上這不是我的原因,即使跳過限制大於提交限制。我在作家的數據中填入了名單。這是它進入無限循環的原因,因爲列表永遠不會用盡。現在我已經解決了這個問題。但仍然不確定這張票。謝謝。 – Vimal
我試圖重現錯誤,但沒有成功 –