通过分区,您应该得到一个StepExecution
回来,不管成功/失败的:
@ServiceActivator
public StepExecution handle(StepExecutionRequest request) {
Long jobExecutionId = request.getJobExecutionId();
Long stepExecutionId = request.getStepExecutionId();
StepExecution stepExecution = jobExplorer.getStepExecution(jobExecutionId, stepExecutionId);
if (stepExecution == null) {
throw new NoSuchStepException("No StepExecution could be located for this request: " + request);
}
String stepName = request.getStepName();
Step step = stepLocator.getStep(stepName);
if (step == null) {
throw new NoSuchStepException(String.format("No Step with name [%s] could be located.", stepName));
}
try {
step.execute(stepExecution);
}
catch (JobInterruptedException e) {
stepExecution.setStatus(BatchStatus.STOPPED);
// The receiver should update the stepExecution in repository
}
catch (Throwable e) {
stepExecution.addFailureException(e);
stepExecution.setStatus(BatchStatus.FAILED);
// The receiver should update the stepExecution in repository
}
return stepExecution;
}
(StepExecutionRequestHandler
)。
随着分块,你应该得到一个ChunkResponse
无论哪种方式...
@ServiceActivator
public ChunkResponse handleChunk(ChunkRequest<S> chunkRequest) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Handling chunk: " + chunkRequest);
}
StepContribution stepContribution = chunkRequest.getStepContribution();
Throwable failure = process(chunkRequest, stepContribution);
if (failure != null) {
logger.debug("Failed chunk", failure);
return new ChunkResponse(false, chunkRequest.getSequence(), chunkRequest.getJobId(), stepContribution, failure.getClass().getName()
+ ": " + failure.getMessage());
}
if (logger.isDebugEnabled()) {
logger.debug("Completed chunk handling with " + stepContribution);
}
return new ChunkResponse(true, chunkRequest.getSequence(), chunkRequest.getJobId(), stepContribution);
}
(ChunkProcessorChunkHandler
)
这对分区;我添加了关于分块的评论。 –
好的。我配置了一个'FaultTolerantChunkProcessor'而不是'SimpleChunkProcessor'(在我下降到1的块大小之前)并且在'ChunkProcessorChunkHandler.process'中处理这个似乎导致异常不传播。我觉得我现在很好。谢谢您的帮助。 –