Results 1 to 3 of 3

Thread: 'retry' for tasklets?

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    9

    Default '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. #2
    Join Date
    Jul 2009
    Posts
    19

    Default

    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>

  3. #3
    Join Date
    Jul 2009
    Posts
    19

    Default

    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>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •