首页 文章

Spring Batch:在写入期间回滚后,Commit-Interval没有兑现

提问于
浏览
1

说我的提交间隔是1000 .

在写作期间,我在第990条记录中得到一个错误,根据跳过政策可以跳过 .

因此将发生回滚,编写器将再次开始从记录1写入相同的记录 .

但是,这一次,它是对每条记录的承诺 . 它不尊重提交间隔 . 这使得工作进展缓慢 .

为什么这样的行为?我在配置中遗漏了什么?

谢谢 .

1 回答

  • 2

    bevaviour对于spring批处理是必须的,以隔离坏项,基本上它回滚块并使用commit-rate = 1处理/写入每个项目以找到坏项(在处理器或编写器中)

    spring batch forum comment to similar problem

    相关部分

    --> 5 items read, processing starts
    <processor called:15>
    <processor called:16>
    <processor called:17> will throw an error on write
    <processor called:18>
    <processor called:19>
    <before write:[15, 16, 17, 18, 19]>
    <on write error>
    --> error on item 17, but it was in the list, lets find it
    --> rollback
    <before chunk>
    --> spring batch goes through all items of the chunk again to find the bad item
    --> basically it runs now with commit-rate="1" (only for this chunk)
    <processor called:15>
    <after write:[15]>
    <after chunk>
    <before chunk>
    <processor called:16>
    <after write:[16]>
    <after chunk>
    <before chunk>
    <processor called:17> called again for the bad item, because it's still unknown to spring batch, that this is the bad one
    --> no write, because itemWriter.write() was called with the bad item only and did throw an exception (again)
    --> but now spring batch knows the bad item
    <before chunk>
    

相关问题