RESOLVED - issue BATCH-654: Transactions when commit fails

This commit is contained in:
dsyer
2008-06-18 10:24:18 +00:00
parent 26d14d2068
commit 345e7a4b81
8 changed files with 186 additions and 9 deletions

View File

@@ -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());
}

View File

@@ -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) {

View File

@@ -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 {