How to manage the transaction(which includes File IO) when an IOException is thrown from the close file method?

Generally speaking, file IO is not transactional (except for some OS-specific features).

Generally speaking, file IO is not transactional (except for some OS-specific features). So, the best you can do is to move open and close operation to write() method, in order to execute them inside a transaction and rollback the transaction if closing fails. Note, however, that you can't rollback the file IO in the case of transaction rollback, so that under some circumstances you can get the correct file with items, whereas in the database these items are not marked as TRANSFERRED.To sove this problem you can try to use low-level transaction management support and try to delete the file in the case of rollback, but I think it still can't provide strong guarantees of consistency: @Transactional(rollbackFor = IOException.

Class) public void write(List itemList) throws IOException { openFile(); TransactionSynchronizationManager(). RegisterSynchronization(new TransactionSynchronizationAdapter() { public void afterCompletion(int status) { if (status = STATUS_ROLLED_BACK) { // try to delete the file } } }); try { ... } finally { closeFile(); } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions