【发布时间】:2019-02-24 16:20:03
【问题描述】:
我需要创建“N”个步骤,具体取决于从数据库接收到的“maxHierLevel”值并按顺序执行它们 -
int maxHierLevel = testService.getHighestLevel();
Step masterCalculationStep = stepBuilderFactory.get("CALCUL_STEP_1")
.<Map<Long, List<CostCalculation>>, List<TempCostCalc>>chunk(1)
.reader(reader)
.processor(processor)
.writer(writer)
.build();
final Step[] stepsArray = new Step[maxHierLevel];
for (int i = 0; i < stepsArray.length; i++) {
stepsArray [i] = stepBuilderFactory.get("processingRecordsInLevel_"+i)
.partitioner("partitionningSlavStep_"+i , calculationPartioner(i))
.step(masterCalculationStep)
.listener(new StepResultListener())
.taskExecutor(taskExecutor)
.build();
}
return jobBuilderFactory.get("mainCalculationJob")
.incrementer(new RunIdIncrementer())
.flow(truncTableTaskletStep())
.next(loadPlantList)
.next(stepsArray[0])
.next(stepsArray[1])
.next(stepsArray[2])
.end()
.listener(listener)
.build();
我们可以动态添加像 next(stepsArray[0]) 这样的步骤并返回作业 ref 吗?
【问题讨论】:
标签: spring spring-batch