Issue Details (XML | Word | Printable)

Key: BATCH-244
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dave Syer
Reporter: Jens Eickmeyer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Batch

Repeated processing of items does not work if exception is in first chunk

Created: 03/Dec/07 03:42 AM   Updated: 07/Aug/08 10:06 AM
Component/s: None
Affects Version/s: 1.0-m3
Fix Version/s: 1.0-m3

Time Tracking:
Not Specified

File Attachments: 1. XML File rollbackJob.xml (4 kB)
2. Java Source File RollbackJobFunctionalTests.java (0.4 kB)
3. Java Source File TradeProcessor.java (2 kB)



 Description  « Hide
If an exception occurs during the processing of a chunk an ExceptionHandler in the StepOperations can be used to signal the framework to rollback the current chunk. It is assumed that the default behaviour of the DefaultStepExecutor used in all the examples has the ability to process all items again that could be handled successfully in the previous execution of the chunk. The item which caused the processing of the chunk to fail should be skipped. Unfortunately this does not work out of the box. An attached example which is based on tradeJob.xml should show this.

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Jens Eickmeyer added a comment - 03/Dec/07 03:44 AM
The configured job just reads a file a puts everything into the database. A second step just prints out all the previously added items.

Jens Eickmeyer added a comment - 03/Dec/07 03:45 AM
Just a unit test for the sample job

Jens Eickmeyer added a comment - 03/Dec/07 03:48 AM
A slightly modified version of the TradeProcessor which just throws an exception on the 5th item a causes a rollback of the current chunk. It is expected that the second step prints out all items except the 5th one because this one should be skipped during the second processing of the chunk which previously failed.

Dave Syer added a comment - 04/Dec/07 03:13 AM - edited
I found (and fixed) a bug in ResourceLineReader which means that if the exception is in the first chunk the failed chunk is not replayed. Can you try your test with chunk size = 2 (less than the failure point) and see if it works as you expected (I'm not clear on what you think the problem is because your unit test didn't have any assertions, but I am clear on the bug).

P.S. I committed your test (with an assertion) in the usual place.

Jens Eickmeyer added a comment - 04/Dec/07 07:43 AM
I tried your fix and it seems to work as expected now. So it was just this special scenario when reading from a file a forcing an error in the first chunk, right?

Dave Syer added a comment - 04/Dec/07 12:17 PM
That seems to be it, so this is resolved.

Dave Syer added a comment - 07/Aug/08 10:06 AM
Assume closed as resolved and released