gpt4 book ai didi

Spring 批处理 : Fault Tolerant

转载 作者:行者123 更新时间:2023-12-04 18:35:14 27 4
gpt4 key购买 nike

我有以下步骤:

    return stepBuilderFactory.get("billStep")
.allowStartIfComplete(true)
.chunk(20000)
.reader(billReader)
.processor(billProcessor)
.faultTolerant()
.skipLimit(Integer.MAX_VALUE)
.skip(BillSkipException.class)
.listener(billReaderListener)
.listener(billSkipListener)
.writer(billRepoItemWriter)
.build();

我的理解是否正确,容错意味着当 billProcessor 中抛出异常时,它将在跳过监听器中处理,然后下一行/项目将在 billProcessor 中处理?

我在添加调试日志时注意到 - 当处理器中抛出异常时,项目/行被“重新处理”。 (可能是因为容错配置。
但是,如果我正在处理 200 万条记录,并且其中的 300,000 条被跳过 - 或者抛出一个跳过异常 - 如果其中一些被“重新处理”,这不是性能问题吗?)

最大的问题是 - 下一行/项目被跳过。它们根本没有在处理器中处理。

如果我删除了 faultTolerant 和 SkipListener - 并直接将跳过的记录保存在数据库中(skiplistener 在做什么) - 它正在工作,但这个解决方案是否正确?

最佳答案

I noticed upon adding in debug logs - that items/rows were "re-processed" when an exception is thrown in the processor. (probably because of faultTolerant config. But, what if I am processing 2 million records, and 300,000 of them were skipped - or throws a skip exception - isn't it an issue in performance if some of these were "re-processed")



我发生了同样的问题,我使用 processorNonTransactional 方法修复了。

    @Bean
public Step myStep() {
return stepBuilderFactory.get("myStep")
.<MyObject, MyObject>chunk(1000)
.reader(myItemReader())
.processor(myItemProcessor())
.writer(jdbcBatchItemWriter())
.faultTolerant()
.processorNonTransactional()
.skip(MyException.class)
.skipLimit(200)
.build();
}

关于 Spring 批处理 : Fault Tolerant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44255167/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com