0

나는 servicemix에 처음 왔는데 servicemix에서 예외 처리를 시도하고있다.아파치 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>] 

기록지고의 예외입니다. 내가 그 메시지가 예외에서 오는 예외 메시지

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

에서 이들을 제거 할 수있는 방법이있다, 그래서 당신은 Processor 내부 문자열을 조작 할 수 있습니다.

이 할 수있는 간단한 클래스 쓰기 : 호기심 멋지군 일이 콩

<doTry> 
    <to uri="validator:http://localhost/employee.xsd"/> 
    <doCatch>           
     <exception>java.lang.Exception</exception> 
     <to uri="bean:exceptionMsgProcessor" /> 
    </doCatch>     
</doTry> 
+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); } 

을 그리고 당신이 알고 왜 예외에 메시지 본문이 포함되어 있습니까? –

+0

@abhipm 예외를 만든 사람은 누구나 해당 정보를 추가합니다. 유효성 검사기 구성 요소 안에 중단 점을 설정하고 예외가 생성되고 throw되는 위치를 확인합니다. –