RESOLVED - issue BATCH-654: Transactions when commit fails
This commit is contained in:
@@ -250,7 +250,7 @@ public class SimpleJobRepository implements JobRepository {
|
||||
* @see org.springframework.batch.core.repository.JobRepository#saveOrUpdateExecutionContext(org.springframework.batch.core.domain.StepExecution)
|
||||
*/
|
||||
public void saveOrUpdateExecutionContext(StepExecution stepExecution) {
|
||||
saveOrUpdate(stepExecution);
|
||||
// Until there is an interface change (
|
||||
stepExecutionDao.saveOrUpdateExecutionContext(stepExecution);
|
||||
jobExecutionDao.saveOrUpdateExecutionContext(stepExecution.getJobExecution());
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
exitStatus = exitStatus.and(getCompositeListener().afterStep(stepExecution));
|
||||
|
||||
try {
|
||||
getJobRepository().saveOrUpdate(stepExecution);
|
||||
getJobRepository().saveOrUpdateExecutionContext(stepExecution);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -211,6 +211,7 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
*/
|
||||
protected ExitStatus doExecute(final StepExecution stepExecution) throws Exception {
|
||||
stream.update(stepExecution.getExecutionContext());
|
||||
getJobRepository().saveOrUpdate(stepExecution);
|
||||
getJobRepository().saveOrUpdateExecutionContext(stepExecution);
|
||||
itemHandler.mark();
|
||||
|
||||
@@ -362,6 +363,12 @@ public class ItemOrientedStep extends AbstractStep {
|
||||
throw new FatalException("Failed while processing rollback", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (fatalException.hasException()) {
|
||||
// Try and give the system a chance to update the stepExecution with
|
||||
// the failure status.
|
||||
getJobRepository().saveOrUpdate(stepExecution);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExceptionHolder {
|
||||
|
||||
Reference in New Issue
Block a user