Spring Batch RetryTemplate意外重试

时间:2015-12-14 14:47:40

标签: spring spring-retry

如果我在我的块中定义跳过限制,则通过FaultTolerantStepBuilder创建重试模板。实际上我不想使用这个RetryTemplate

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

如果我的ItemWriter org.springframework.retry.support.RetryTemplate#handleRetryExhausted发生故障,我的ItemWriter会再次调用,并且没有办法阻止第二次调用。设置重试策略对此调用没有影响。

你能帮帮我吗?我找不到阻止此重试的正确方法。

<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");
}

}

0 个答案:

没有答案