【问题标题】:Spring Batch Job Infinite LoopSpring Batch 作业无限循环
【发布时间】: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


    【解决方案1】:

    有一个open ticket关于这个问题

    【讨论】:

    • 虽然存在问题,但您会注意到我们无法重现此行为。如果你能贡献一个测试用例,这将对我们修复它有很大帮助。
    • 感谢您的回复。我已经看到了这个无限循环问题的开放票,但实际上这不是我的情况的原因,即使跳过限制大于提交限制。我正在用 writer 中的数据填充列表。这就是它进入无限循环的原因,因为列表永远不会用完。现在我已经解决了这个问题。但仍然不确定这张票。谢谢。
    猜你喜欢
    • 2020-03-09
    • 1970-01-01
    • 2019-06-09
    • 1970-01-01
    • 1970-01-01
    • 2014-12-24
    • 1970-01-01
    • 2016-10-03
    • 2019-06-10
    相关资源
    最近更新 更多