gpt4 book ai didi

spring - 在Spring批处理中循环

转载 作者:行者123 更新时间:2023-12-04 04:48:32 24 4
gpt4 key购买 nike

第一步,我在Spring Batch中具有以下简单配置:

<batch:job id="collaborationJob" >
<batch:step id="collaborationJobStep1">
<batch:tasklet>
<batch:chunk reader="collaborationAlertReader" processor="WriteCollaborationPruningProcessor" writer="alertCollaborationPruningWriter"
commit-interval="10">
</batch:chunk>
</batch:tasklet>
<batch:next on="*" to="collaborationJobStep2" />
<batch:next on="FAILED" to="collaborationJobStep4"/>
</batch:step>


如果我在itemReader中读取的行数小于10,那么一切都很好,但是如果行数大于等于10,我将进入重复循环:

2015-09-29 17:02:40,782 DEBUG [org.springframework.batch.core.step.tasklet.TaskletStep] - <Saving step execution before commit: StepExecution: id=1332, version=878, name=collaborationJobStep1, status=STARTED, exitStatus=EXECUTING, readCount=8780, filterCount=0, writeCount=8780 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=878, rollbackCount=0, exitDescription=>

2015-09-29 17:02:40,786 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=879>

2015-09-29 17:02:40,786 DEBUG [org.springframework.batch.core.scope.context.StepContextRepeatCallback] - <Preparing chunk execution for StepContext: org.springframework.batch.core.scope.context.StepContext@664020c7>

2015-09-29 17:02:40,786 DEBUG [org.springframework.batch.core.scope.context.StepContextRepeatCallback] - <Chunk execution starting: queue size=0>

2015-09-29 17:02:40,787 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Starting repeat context.>

2015-09-29 17:02:40,787 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=1>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=2>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=3>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=4>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=5>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=6>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=7>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=8>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=9>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat operation about to start at count=10>

2015-09-29 17:02:40,791 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Repeat is complete according to policy and result value.>

2015-09-29 17:02:40,793 DEBUG [org.springframework.batch.core.step.item.ChunkOrientedTasklet] - <Inputs not busy, ended: false>

2015-09-29 17:02:40,793 DEBUG [org.springframework.batch.core.step.tasklet.TaskletStep] - <Applying contribution: [StepContribution: read=10, written=10, filtered=0, readSkips=0, writeSkips=0, processSkips=0, exitStatus=EXECUTING]>


我的配置有什么问题?
提前致谢
乔治

最佳答案

应用于块的某些策略(甚至是DefaultResultCompletionPolicy)正在等待读取结束(读取器中的read()方法需要在不再读取任何内容时返回null)。

因此,请在阅读器read中检查您的collaborationAlertReader方法是否在读取完成后返回null(例如,如果read方法返回空列表,则您的步骤将陷入无限循环)。

关于spring - 在Spring批处理中循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32857917/

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