Announcement Announcement Module
Collapse
No announcement yet.
Stop retry in chunk processing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:streams>
    <batch:stream ref="badItemWriter" />
    </batch:streams>
    <batch:skippable-exception-classes>
    java.lang.Exception
    </batch:skippable-exception-classes>
    </batch:chunk>
    <batch:listeners>
    <batch:listener ref="baseSkipListener" />
    <batch:listener ref="dataCopyMailListener" />
    </batch:listeners>
    </batch:tasklet>
    <batch:next on="COMPLETED" to="filePurge" />
    <batch:end on="FAILED" />
    </batch:step>

    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.

    Comment


    • #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 !

      Comment


      • #4
        Hi
        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="http://www.springframework.org/schema/batch" incrementer="jobParametersIncrementer">
        <step id="step1" parent="simpleStep">
        <tasklet>
        <chunk reader="reader" writer="writer" skip-limit="4" processor-transactional="false" >
        <skippable-exception-classes>
        <include class="java.lang.Exception" />
        </skippable-exception-classes>
        </chunk>
        </tasklet>
        </step>
        </job>
        <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.

        Comment


        • #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!!

          Comment


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

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

            "noRetry" is defined as:

            Code:
            <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...

            Comment

            Working...
            X