2013-03-14 64 views
0

我有春天批次就地,我想配置一个重试逻辑我得到了以下配置:我怎么能确认重试工作在春季批次impelmentation

<step id="roundUpMonthlyJobFetchUsers"> 
      <tasklet> 
       <chunk reader="roundUpMonthlyItemReader" processor="roundUpMonthlyItemProcessor" 
         writer="roundUpMonthlyItemWriter" commit-interval="1" retry-limit="3" > 
        <retryable-exception-classes> 
         <include class="java.io.IOException" /> 
        </retryable-exception-classes> 
       </chunk> 
      </tasklet> 
     <end on="COMPLETED"/> 
    <fail on="FAILED"/> 
</step> 

如何cofirm这个公司实际上是试图要为atleast 3次做手术时遇到IOException异常

回答

0

更改这个类roundUpMonthlyItemReader

要登录入口的东西,然后抛出IOException异常每次,然后检查日志:)

log.info("Reading Monthly round up"); 
throw new IOException("Dummy IOException"); 

如果你想做到这一点在单元测试中,你应该能够使用的Mockito到

  • 模拟读者或作家抛出IOException
  • 确保它被称为3倍
+0

我已经尝试过,但是当我抛出异常它出现在日志只有一个不是三次。我不知道如果我需要实现retrytemplate,并把逻辑放在那里,我想在重试中运行,它没有任何意义,因为当然我想运行相同的步骤,但只是困惑,因为我记录我只看到这个异常一次是重试或不重试:S – 2013-03-14 11:45:20

+0

及其roundUpMonthlyItemProcessor,我希望它重试。 – 2013-03-14 11:52:09