【发布时间】:2013-10-15 18:24:53
【问题描述】:
在产品发布的最后一分钟,我发现 Java Spring Batch 存在一个奇怪的问题。进入无限循环。
这是我的配置:
<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。因此,提交发生在处理完每条记录之后。 我正在将结果写入 Writer 中的数据库。
我正在从阅读器中一一获取项目,处理并写入数据库。
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...
它不断运行并将数据无限插入到表中。
观察是:Commit-Interval Commit-Interval。
如果有人提出一些解决方案/解决方法,那么在因为这个问题而举行生产发布的时间点对我有最大的帮助。
非常感谢。
【问题讨论】:
标签: spring-batch