我有一个必须为项目列表重复的批处理作业。所以我有一个“父”作业,它使用批处理步骤来加载列表并为列表中的每个 id 启动一个子作业。每个子作业都是使用JobOperator和使用Properties类的参数启动的,这可以按预期工作。
我必须检索批处理状态并等待子作业完成,以便遍历列表。我正在尝试使用JobExecution类获取批处理状态或退出状态,但是JobExecution没有检索子作业的批处理状态。
相反,我总是看到 的批处理状态STARTED
,即使在子作业完成后也是如此。
我的代码如下所示:
for (int i = 1; i <= rsList; i++) {
long execId = jobOperator.start("gah-history-chunk-archive-job",jobParamProperties);
JobInstance jobInstance = jobOperator.getJobInstance(execId);
JobExecution jobExecution = jobOperator.getJobExecution(execId);
logger.info("Instance id: "+jobInstance.getInstanceId());
while(!jobExecution.getBatchStatus().toString().equals("COMPLETED") || !jobExecution.getBatchStatus().toString().equals("FAILED")) {
//Both batch status and exit status giving the status of this batchlet, not giving the status of gah-history-chunk-archive-job
logger.info("Batch status is: "+jobExecution.getBatchStatus() +" Thread is sleeping for 5 seconds");
logger.info("Exit status:"+jobExecution.getExitStatus());
Thread.sleep(300);
}
}
我想知道,如何检索从批处理启动的子作业的批处理或退出状态。为什么我继续看到 BatchStatus STARTED
?