2013-02-19 54 views
0

我試圖讓Mule記錄我的SOAP組件在以下流程中引發的異常。例如,如果我將它格式錯誤的xml作爲輸入傳遞給soapUI,我會得到一個有意義的輸出,但我希望能夠將其記錄在控制檯中或將其發送到JMS隊列。在Mule ESB中記錄SOAP錯誤

<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/> 
<flow name="CAB-Mule_WMBFlow1" doc:name="CAB-Mule_WMBFlow1"> 
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8081/DemoCustomer" doc:name="HTTP" mimeType="text/xml"> 
     <idempotent-redelivery-policy maxRedeliveryCount="3"> 
      <dead-letter-queue> 
       <vm:outbound-endpoint path="error-queue" /> 
      </dead-letter-queue> 
     </idempotent-redelivery-policy> 
    </http:inbound-endpoint> 
    <cxf:jaxws-service port="80" serviceClass="com.mulesoft.demo.DemoCustomer" doc:name="SOAP"/> 
    <component class="com.mulesoft.demo.DemoCustomerIntImpl" doc:name="Java"/> 
    <jms:outbound-endpoint queue="StudioIN" connector-ref="Active_MQ" doc:name="JMS"/> 
    <logger level="INFO" doc:name="Logger" message="Payload: #[payload]"/> 
</flow> 
<flow name="error" doc:name="error"> 
    <component class="com.mulesoft.demo.ExceptionService" doc:name="Java"/> 
    <jms:outbound-endpoint queue="Error" connector-ref="Active_MQ" doc:name="JMS"/> 
</flow> 

ExceptionService就是:

public class ExceptionService { 
    public void onException(ExceptionMessage e) { 
     System.err.println("EXCEPTION MESSAGE:::: " + e.getException().getMessage()); 
    } 
} 

回答

0

定義<catch-exception-strategy>CAB-Mule_WMBFlow1結束前,像這樣和日誌,推動該錯誤消息。JMS隊列

<flow name="CAB-Mule_WMBFlow1" doc:name="CAB-Mule_WMBFlow1"> 
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8081/DemoCustomer" doc:name="HTTP" mimeType="text/xml"> 
     <idempotent-redelivery-policy maxRedeliveryCount="3"> 
      <dead-letter-queue> 
       <vm:outbound-endpoint path="error-queue" /> 
      </dead-letter-queue> 
     </idempotent-redelivery-policy> 
    </http:inbound-endpoint> 
    <cxf:jaxws-service port="80" serviceClass="com.mulesoft.demo.DemoCustomer" doc:name="SOAP"/> 
    <component class="com.mulesoft.demo.DemoCustomerIntImpl" doc:name="Java"/> 
    <jms:outbound-endpoint queue="StudioIN" connector-ref="Active_MQ" doc:name="JMS"/> 
    <logger level="INFO" doc:name="Logger" message="Payload: #[payload]"/> 

    <catch-exception-strategy> 
     <logger level="INFO" message="---->Exception payload is: #[payload]"/> 
     <jms:outbound-endpoint queue="Error" /> 
    </catch-exception-strategy> 
</flow> 

此外,您可以使用message.getExceptionPayload().getMessage()在java組件中獲取異常消息並在控制檯上輸出,消息類型爲MuleMessage

+0

似乎沒有爲我工作,我沒有得到記錄器消息到控制檯和錯誤隊列也沒有得到任何消息。我是否也必須設置全球例外策略? – 2013-02-19 22:21:35