Announcement Announcement Module
Collapse
No announcement yet.
'retry' for tasklets? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 'retry' for tasklets?

    Does the ability to retry a tasklet exist? I have already ran my batch steps and my final step simply renames a file. If an error occurs here I want it to retry but as this is outside of the chunk processing I don't see an easy way to retry it.

  • #2
    I wish it's in next release. The work around we're using is AOP, hope this help-

    Code:
        <aop:config>
            <aop:pointcut id="batchJobRetry"
                          expression=" execution(* *..*YourTasklet.execute(..))  "/>
            <aop:advisor pointcut-ref="batchJobRetry" advice-ref="retryAdvice" order="-1"/>
        </aop:config>
    
        <bean id="retryAdvice"
                    class="org.springframework.batch.retry.interceptor.RetryOperationsInterceptor">
            <property name="retryOperations">
                <bean class="org.springframework.batch.retry.support.RetryTemplate">
                    <property name="retryPolicy">
                        <bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
                            <property name="maxAttempts" value="10"/>
                            <property name="retryableExceptionClasses">
                                <list>
                                    <value>org.apache.commons.vfs.FileSystemException</value>
                                    <value>org.springframework.batch.retry.RetryException</value>
                                </list>
                            </property>
                        </bean>
                    </property>
                    <property name="backOffPolicy">
                        <bean class="org.springframework.batch.retry.backoff.FixedBackOffPolicy">
                            <property name="backOffPeriod" value="10000"/>
                        </bean>
                    </property>
                </bean>
            </property>
        </bean>

    Comment


    • #3
      Now I have problem to configure chunk to retry. For example my FlatFileItemReader is configured to load a daily csv file on a ftp site, I'd like it keep trying until the file is available.The following doesn't work. It's terminated right away without retrying with ItemStreamException. Does anybody have any idea? Also, how can I inject my own retry policy without AOP to this itemReader? Thanks

      Code:
      <batch:chunk reader="itemReader" writer="itemWriter" commit-interval="1000" retry-limit="3">
      	<batch:retryable-exception-classes>
      		org.springframework.batch.item.ItemStreamException
      	</batch:retryable-exception-classes>
      </batch:chunk>

      Comment

      Working...
      X