• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic