The FlatFileItemWriter uses a TransactionAwareBufferedWriter by default. The TransactionAwareBufferedWriter delays writing to the underlying buffer to the point where the transaction is actually committed. To achieve this, it registers a TransactionSynchronization with spring's TransactionSynchronizationManager. When the transaction commits, it is the TransactionSynchronizationUtils that will actually call the synchronization as follows:
So when there is an IOException when the actual write to the underlying buffer occurs, it is just logged and ignored. The batch job will happily continue with the next chunk. Or am I missing something here?Code:public static void invokeAfterCompletion(List<TransactionSynchronization> synchronizations, int completionStatus) { if (synchronizations != null) { for (TransactionSynchronization synchronization : synchronizations) { try { synchronization.afterCompletion(completionStatus); } catch (Throwable tsex) { logger.error("TransactionSynchronization.afterCompletion threw exception", tsex); } } } }


Reply With Quote