Two Laptop Bag*
The moose likes Spring and the fly likes SpringBatch: 'update' method in ItemStream and roll back in case of exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "SpringBatch: Watch "SpringBatch: New topic
Author

SpringBatch: 'update' method in ItemStream and roll back in case of exception

Haq Yunus
Ranch Hand

Joined: Apr 08, 2009
Posts: 42
Hello,

My Writer (FlatFileWriter) implements the 'update' and 'open' methods of the ItemStream class. I know that the update method is called after the writing of the chunk is fnished but NOT yet committed. So this gives us a guarantee that if saving of the state in the update method itself fails, our just written chunk will also be rolled-back. This seems to be working as I have tested it.

Now what I am noticing is that if I have placed something in the ExecutionContext in the update method of ItemStream in the Writer class, that stuff or those values are not rolled back or discarded if there was in Exception in the update method. How I simulated this was that in the update method:



Now when the exception is thrown then my last written chunk is successfully rolled back but on the restart I get the value 1 for "restart_value" attribute. Shouldn't this be discard as well? Or I have to roll back or clear the Execution Context myself? I believe some sort of 2 phase commit is implemented here.

What is exception occurs within super.update where I do not have any control? Please advise. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SpringBatch: 'update' method in ItemStream and roll back in case of exception
 
Similar Threads
UNCLEAR - Does transaction propogate to JDBC DAO?
Partioning with String based key
JPA exceptions and JTA rollback
rollback in LDAP
Spamming transactions breaks Hibernate?