Spring Batch-Repeat step for each item in a data list 질문에서 논의 된 것처럼 Partitioning이 해결책 인 것 같습니다. PartitionHandler에 대한
구성 :
<batch:step id="anyNameJobMaster">
<batch:partition step="nameOfActualStepToBeIterated" partitioner="partitioner">
<batch:handler grid-size="10" task-executor="taskExecutor" />
</batch:partition>
</batch:step>
<bean id="partitioner" class="org.example.PartitionerThatImplementsPartitioner" lazy-init="true" scope="step"/>
PartitionHandler 샘플 코드 :
public class PartitionerThatImplementsPartitioner implements Partitioner{
@Override
public Map<String, ExecutionContext> partition(int gridSize) {
Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize);
//Iteration goes here
//For Each Iteration, create ExecutionContext and add it to map.
map.put("somePartionKeyString", new ExecutionContext().put("ContextIdentifiere.g.FileName", "IteratedVale.g.FilePath"))
}
}
작업 구성 :
<batch:step id="nameOfActualStepToBeIterated">
<batch:tasklet transaction-manager="someTxManager">
<batch:chunk processor="someProcessor"
writer="itemWriter" commit-interval="${commitInterval}">
<batch:reader>
<bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<property name="resource" value="#{stepExecutionContext['ContextIdentifiere.g.FileName']}" />
</bean>
</batch:reader>
</batch:chunk>
</batch:tasklet>
당신이 항목 프로세서를 체인으로 간주 있나요? http://docs.spring.io/spring-batch/reference/html/readersAndWriters.html#chainingItemProcessors –
내 직업은 다음과 같아야합니다. 1. 읽기 목록 2. 목록에서 항목 하나를 가져 와서 처리하십시오. 3. reader -> processor -> writer 4. 목록에 항목이 더 있으면 2 단계에서 반복하십시오. 그래서 어떤 프로세서도 연결할 수 없습니다. –
그 말은 상당히 일반적인 작업 프로세스처럼 들립니다. 읽기 -> 프로세스 -> 쓰기. 문제가 무엇인지 알 수없는 점은 무엇입니까? –