gpt4 book ai didi

spring-batch - 多线程作业中的 Spring Batch Reader

转载 作者:行者123 更新时间:2023-12-04 03:56:14 26 4
gpt4 key购买 nike

我正在使用 Spring Batch 来运行我的 JOBS
当读者是 org.springframework.batch.item.database.JpaPagingItemReader

我的 JOB 配置了参数:
throttle 限制=“6”

从读取器读取数据时是否存在线程数据冲突?

为什么我要恢复以下警告:

[org.springframework.batch.core.step.item.ChunkMonitor:109] - No ItemReader set (must be   concurrent step), so ignoring offset data.
[org.springframework.batch.core.step.item.ChunkMonitor:141] - ItemStream was opened in a different thread. Restart data could be compromised.
[org.springframework.batch.core.step.item.ChunkMonitor:141] - ItemStream was opened in a different thread. Restart data could be compromised.
[org.springframework.batch.core.step.item.ChunkMonitor:141] - ItemStream was opened in a different thread. Restart data could be compromised.

最佳答案

JpaPagingItemReader是线程安全的,因为使用它从多个线程读取是可以的,当通过多个线程使用时,该读取器将不支持重新启动。警告确实表明您需要将保存状态设置为 false ( JpaPaginingItemReader#setSaveState(boolean) )。此类的文档讨论了将保存状态设置为 false 的必要性:http://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/item/database/JpaPagingItemReader.html

这样做的原因是重启状态最终会在所有线程之间共享,因此它们最终会相互踩踏。

关于spring-batch - 多线程作业中的 Spring Batch Reader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23780587/

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