0

私はservicemixに新しく、servicemixで例外処理を試みています。apache servicemixでの例外処理

私は例外を印刷しようとすると、それはまたそれの要求の本体をconatinsします。 私は例外からエラーだけを抽出することができる方法はありますか?以下

<from uri="activemq:topic://topic1"/> 
      <!-- Schema validationm for the request received from Biblio --> 
      <doTry> 
       <to uri="validator:http://localhost/employee.xsd"/> 
       <doCatch>           
        <exception>java.lang.Exception</exception> 
        <log message="${exception.message}"/>   
       </doCatch>     
      </doTry> 

は私が正しい例外を取得していますが、私は例外で部未満たくない

[email protected] 
errors: [ 
org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: 'asd' is not a valid value for 'integer'., Line : -1, Column : -1 
org.xml.sax.SAXParseException: cvc-type.3.1.3: The value 'asd' of element 'empnumber' is not valid., Line : -1, Column : -1 
]. Exchange[ID-GBSMIXDEV01-uk-oup-com-46713-1511957485149-83-2][Message: <empRecord>   
     <employee> 
      <empnumber>asd</empnumber>    
      <surname>PM</surname>    
      <firstname>Abhinay</firstname> 
     </employee> 
     </empRecord>] 

をログに記録取得される例外です。私はあなたがProcessor内の文字列を操作することができるようにメッセージが、例外から来ている例外メッセージ

Exchange[ID-GBSMIXDEV01-uk-oup-com-46713-1511957485149-83-2][Message: <empRecord>   
     <employee> 
      <empnumber>asd</empnumber>    
      <surname>PM</surname>    
      <firstname>Abhinay</firstname> 
     </employee> 
     </empRecord>] 

答えて

0

からこれらを削除することができますどのような方法があります。

これを行うための単純なクラス書く:

private static final Logger logger_ = LoggerFactory 
     .getLogger(ExceptionMsgProcessor.class); 

public void process(Exchange exchange) { 
    Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); 
    String msg = e.getMessage(); 
    // manipulate the string here 
    log.info("Exception message: {}", msg); 
} 

をそして好奇心からfine.Justを働いたおかげアレッサンドロ:) は、あなたが知っているこのBeanに

<doTry> 
    <to uri="validator:http://localhost/employee.xsd"/> 
    <doCatch>           
     <exception>java.lang.Exception</exception> 
     <to uri="bean:exceptionMsgProcessor" /> 
    </doCatch>     
</doTry> 
+0

を例外を送信します例外にメッセージ本文が含まれているのはなぜですか? –

+0

@abhipm例外を作成した人は、その情報を追加するだけです。バリデータコンポーネント内にブレークポイントを設定し、例外が作成されてスローされる場所を確認してください:-) –