Announcement Announcement Module
Collapse
No announcement yet.
Question about the retry mechanism Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about the retry mechanism

    Hi,

    I've been trying to add a retry policy to my batch but I can't seem to understand the mechanism behind the simplest retry configuration.

    I have a chunk step defined like that :

    Code:
    <batch:chunk  reader="preventionCaseReader" processor="caseConsUpdateProcessor" 
    writer="updateConsumptionWriter" commit-interval="5" retry-limit="2">
    				
    	<batch:retryable-exception-classes>
    		<batch:include class="org.hibernate.StaleStateException"/>
    		<batch:include class="org.hibernate.OptimisticLockException"/>
    	</batch:retryable-exception-classes>
    </batch:chunk>
    The reader sends a Long to the processor, which sends a persistent entity to the writer.

    From what I understand, when one of these exceptions occur, the processing and the writing parts are retried. So, I was expecting something like that :

    [Processing] Items : 1, 2, 3 ,4 ,5
    =>
    [Writing] Items : [1,2,3,4,5]
    => Writing failed, go back to [Processing]

    But instead, I get this :
    [Processing] Items : 1, 2, 3 ,4 ,5
    => [Writing] Items : [1,2,3,4,5]
    => Writing failed
    => [Processing] Item : 1
    => [Writing] Items [1,2,3,4,5]

    What I fail to understand is : why am I only having the first item reprocessed with the writer getting a list with all 5 items ?

    I read somewhere that the retry mechanism doesn't know which item caused the failure. I understand that point, and that would explain the reprocessing one by one. But that doesn't explain why the writer doesn't write one by one too.

    Is that how this is supposed to work or am I missing something important here ?
    If this is intended, is there a solution to have all the items reprocessed when retrying ?

    I am using Spring Batch 2.1.6.

    Thanks in advance for the help !
    Last edited by Pastissad; May 12th, 2011, 10:36 AM.
Working...
X