2015-12-21 108 views
1

我有一個奇怪的行爲與onException塊。駱駝onException行爲與分割器

如果我將處理設置爲false,那麼不會打印SOME MESSAGE日誌,但如果將處理值更改爲true,則會記錄所有內容。有人能解釋發生了什麼嗎?據我所知,在這兩種情況下都應該打印日誌。

<camelContext ..> 
    <onException> 
     <exception>java.lang.Exception</exception> 
     <handled> 
      <constant>false</constant> 
     </handled> 
     <log message="SOME MESSAGE"/> 
    </onException> 

    <route> 
     <from uri="timer://foo?repeatCount=1"/> 

     <!-- Put a list with some values as a body --> 
     <to uri="bean:utils?method=setBody"/> 

     <split shareUnitOfWork="true" stopOnException="true"> 
      <simple>${body}</simple> 

      <to uri="direct:handleSplit"/> 
     </split> 
    </route> 

    <route> 
     <from uri="direct:handleSplit"/> 
     <throwException ref="myException"/> 
    </route> 
</camelContext> 

回答

0

這對我來說看起來像一個駱駝臭蟲。您的代碼的Java DSL版本不會表現出這種奇怪的行爲:

 onException().handled(false).log(LoggingLevel.INFO, "SOME MESSAGE"); 
     from("timer://foo?repeatCount=1") 
       .to("bean:utils?method=setBody") 
       .split() 
       .body() 
       .throwException(new RuntimeException()); 

無論此處處理的值是多少,都會調用LogProcessor。

切換到Java DSL或填寫錯誤報告。

+0

如果使用shareUnitOfWork選項運行Java DSL版本,則行爲將會相同。 –