2015-08-21 34 views
0

我有如下所示的樣品輸入文件上failuire重試。我希望spring批處理來重新處理異常。然而,處理和重試不應該在整個輸入上,而是在列表(記錄)級別上。例如在處理記錄1001,1002 & 1003,如果再失敗,1002春季批次應着手1003Spring Batch的讀取和在XML列表(而不是整個文件)

<company> 
    <record refId="1001"> 
     <name>mkyong</name> 
     <age>31</age> 
     <dob>31/8/1982</dob> 
     <income>200,000</income> 
    </record> 


<record refId="1002"> 
     <name>kkwong</name> 
     <age>30</age> 
     <dob>26/7/1983</dob> 
     <income>100,999</income> 
    </record> 

    <record refId="1003"> 
     <name>joel</name> 
     <age>29</age> 
     <dob>21/8/1984</dob> 
     <income>1,000,000</income> 
    </record> 
    . . . . . . 
</company> 

春天批量配置前三次重試。

parent="basedStep"> 
     <batch:description>For sending out alerts</batch:description> 
     <tasklet> 
     <chunk reader="cam.ingestedFile.reader" processor="cam.ingestion.pps.processor" retry-limit="3" commit-interval="1" skip-limit="${batch.tolerance.skip.limit}" > 

      <skippable-exception-classes> 
       <include class="com.cam.exception.EBNoAcknowledgementException"/>     
      </skippable-exception-classes>  
      <retryable-exception-classes> 
       <include class="com.cam.exception.EBNoAcknowledgementException"/> 
      </retryable-exception-classes> 
     </chunk>   
      <transaction-attributes isolation="READ_COMMITTED" ></transaction-attributes> 
     </tasklet> 

    </batch:step> 
+1

抱歉,但我無法理解的地步。你嘗試過這份工作嗎?結果是哪一個? –

+0

當我運行作業,它從一開始就重新開始..我是它重試它失敗,... – Jagib

+0

你確定你的自定義閱讀器是用來管理流重啓(如ItemStream執行)繼續前進? –

回答

1

修改讀者以下,它的工作:

<bean id="cam.ingestedFile.reader"class="org.springframework.batch.item.xml.StaxEventItemReader"> 
    <property name="fragmentRootElementName" value="record" /> 
相關問題