Apr 25th, 2011, 10:55 AM
Setting the reading pointer with FlatFileItemReader
Hi All !
I am implementing a batch framework. Our batch strategy is such that if a job fails, upon restart it should start processing the flat file right after the line it successfully read and committed to the database. However, I am having trouble implementing such a strategy.
My current configuration is such that if a job fails, upon restarting it starts from the line it last read (not committed). So for example: lets say my flat file has 6 lines and my chuck size is 2. If an exception occurs lets say during the first chunk. Then when I restart the job it starts processing from line 3 and skips the first 2. The first two lines were never committed to the database since exception caused a roll back.
The above behavior is expected since ItemReaders are forward only. However, I was hoping that if I set the reader-transactional-queue="true" then ItemReader , on restarting the job would read again from line 1 rather than line 3.
It doesn't happen so. When I set the above attribute to true, my job skips the first 2 lines on exception and continues to process the reaming lines. This is not what I expected. I was hoping for the job to fail on encountering an exception like it did above and I was hoping when I retstart it would read again from line 1.
Could anyone help me with this ? Any pointers are greatly appreciated.