5

I have an application that uses Spring Batch 3.0.6. The Spring Batch job uses chunk processing. The commit interval is set to 100 and the retry limit is set to 5.

The writer writes a data chunk (of 100 records) to another application (via TCP) when the commit interval is reached. If one of the records is bad (for whatever reason it causes an exception), then Spring Batch attempts to write the chunk 5 times (the retry limit) and fails each time (as expected).

Spring Batch then attempts to find out which of the 100 records in the chunk is failing by retrying them one at a time (i.e commit interval = 1). This seems to be the default behavior for retry.

Is there a way to be more efficient by retrying, say, 10 records at a time and progressively narrowing the retry size till the offending record is located. That way if the 95th record is bad, then we find it faster than checking them one at a time starting from record 1.

I found this post from 2011:

Spring Batch: Commit-Interval not honored after roll back during write

Is there a way to have SB try smaller chunks first to narrow down the location of the bad record. The smaller chunk size (say, 10 items) can be an optional user configurable item and after that SB can try one item at a time to find the bad record.

Community
  • 1
  • 1
  • One thing you can do to create your custom writer which wraps the writer (one that writes to the database ) until the all records are done , So you have all control on that customized writer. – surya Feb 16 '16 at 00:33
  • the custom writer approach might lead to really long running transactions – Michael Pralow Feb 16 '16 at 08:10
  • Seeing that that logic is implemented in the private method `scan` of `FaultTolerantChunkProcessor`, you're probably need to override a good chunk of that class (at least the `write` method) and then instantiate that instead. – Artefacto Feb 18 '16 at 02:42
  • 1
    In short...no. This isn't possible with the current code without significant modifications. – Michael Minella Feb 18 '16 at 17:34
  • Thank you everyone for your responses. I was looking to configure SB to retry with more than 1 record at a time and Michael M. gave me the answer I needed. – Alan Miranda Feb 24 '16 at 00:12

0 Answers0