Announcement Announcement Module
No announcement yet.
Stop retry in chunk processing Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stop retry in chunk processing

    The following is the use case for my batch. Read from the database, process the item by calling a web service, update the item in the database using item writer. I am returning the exception in the processor when the processing fails. The problem is it retries the chunk from element 0 again and that is causing my successfully processed items being reprocessed. In this case, it is a web service and hence cannot be rollback. Here is the snippet of the configuration in my job.
    <batch:step id="loadData" parent="simpleStep">
    <batch:tasklet transaction-manager="transactionManager">
    <batch:chunk reader="sourceReader" processor="cbrItemProcessor"
    writer="targetWriter" skip-limit="1000000">
    <batch:stream ref="badItemWriter" />
    <batch:listener ref="baseSkipListener" />
    <batch:listener ref="dataCopyMailListener" />
    <batch:next on="COMPLETED" to="filePurge" />
    <batch:end on="FAILED" />

    I did set the retry-limit=0 and still the retry couldnt be avoided. Could someone please help me on this?

  • #2
    set the processor-transactional attribute to false in the chunk tag. Processed items won't be retried then.


    • #3
      I can't thank you enough for this reply ! We had spent almost 2 days on a similar issue and this post saved our day !
      Apologies, for digging out such an old thread !


      • #4
        i have a similar problem, i only have a reader and writer. i am using the Example item reader and Example item writer, with slight modifications.
        here is my job config
        <job id="job1" xmlns="" incrementer="jobParametersIncrementer">
        <step id="step1" parent="simpleStep">
        <chunk reader="reader" writer="writer" skip-limit="4" processor-transactional="false" >
        <include class="java.lang.Exception" />
        <bean id="reader" class="example.ExampleItemReader" />
        <bean id="writer" class="example.ExampleItemWriter" />

        my writer just throws java.lang.exception for every call. on every failed writer call, the writer called again. how can i prevent this. i have tried setting processor-transactional and it didnt work.
        greatly appreciate help on this. its been more than 2 days trying this. seems very basic but didnt work.


        • #5
          Originally posted by arno View Post
          set the processor-transactional attribute to false in the chunk tag. Processed items won't be retried then.
          Thanks a ton!!


          • #6
            Hm, any new advice on this topic? I've also got a rather simple setup using only a reader and a writer:

            <batch:step id="build.step.abstract" abstract="true">
                    <batch:chunk writer="build.writer" commit-interval="1" skip-policy="continue" retry-policy="noRetry" />
                            <ref bean="build.write.listener"/>
            (Reader defined in concrete step implementations)

            "noRetry" is defined as:

            <bean id="noRetry" class="org.springframework.retry.policy.NeverRetryPolicy" />
            This setup does not have the desired effect - exceptions in the writer still cause the respective item to be handed over to the writer for a retry, no matter whether I configure an appropriate retry-policy (above) or a retry-limit (0 not allowed). processor-transactional="false" has no effect either...