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.
subject: SpringBatch: 'update' method in ItemStream and roll back in case of exception