1

if i define a skip-limit in my chunk then a retrytemplate is created through FaultTolerantStepBuilder. Actually i do not want to use this RetryTemplate.

org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean#isFaultTolerant

in case of a failure in my ItemWriter org.springframework.retry.support.RetryTemplate#handleRetryExhausted calls my ItemWriter again and there is no solution to block this second call. Setting a retry policy has no effect on this call.

Could you please help me? I can not find a correct way to block this retry.

<batch:job id="order">
    <batch:step id="orderStep1">
        <batch:tasklet>
            <batch:chunk reader="orderItemReaderAdapter" writer="orderItemWriter"
                         commit-interval="1" skip-limit="20" >
                <batch:skippable-exception-classes >
                    <batch:include class="java.lang.Exception"/>
                </batch:skippable-exception-classes>
            </batch:chunk>
            <batch:listeners>
                <batch:listener ref="orderBatchListener"/> 
            </batch:listeners>
        </batch:tasklet>
    </batch:step>
</batch:job>

<bean id="orderItemWriter" class="com.tr.xxx.xx.batch.write.OrderItemWriter" >
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

public class OrderItemWriter extends HibernateItemWriter<OrderTable>{
private static final Logger LOG = LoggerFactory.getLogger(OrderItemWriter.class);

@Autowired
private OrderServiceClient orderServiceClient;
@Autowired
private SessionFactory sessionFactory;

@Override
public void write(List<? extends OrderTable> items) {
    OrderTable order = items.get(0);
    LOG.info("order will be submitted  {}", order.getId());
    OrderRequest orderRequest = OrderRequest.creatBLOrderRequest(order);
    orderServiceClient.order(orderRequest);
    order.setModifiedBy("batch");
    super.write(items);
    LOG.info("submitted order is marked");
}

}

whoami
  • 31
  • 4
  • Could you attach the code? – Gergely Bacso Dec 14 '15 at 16:36
  • i attached the code. This is the recovery call of RetryTemplate which makes the second call on my ItemWriter. I think this is a must call. Why somebody does need such a recovery instead configuring a retry call? How can i distinguish between these calls in my itemwriter write method? Thank you very much – whoami Dec 14 '15 at 17:33
  • Looks like this is a conceptual issue. There are some debates between users and Spring devs on how and why was this feature implemented this way. The second answer here offers a possible workaround, try it if you have the time: http://stackoverflow.com/questions/22522681/spring-batch-skip-exception-for-itemwriter . – Gergely Bacso Dec 15 '15 at 07:48
  • thank you very much for your help. Now i am sure that is a conceptual issue. – whoami Dec 15 '15 at 08:50

0 Answers0