Mule-esb:使用Choice Router根据状态代码处理Jersey响应?

时间:2013-11-05 04:36:51

标签: mule

如何根据Jersey Rest201处理503服务响应?我可以将groovy和其他评估者混在一起吗?在我的例子中,部分是使用消息属性和其他groovy

<flow> 
    <http:outbound-endpoint address="${host}" exchange-pattern="request-response"/>
    <when expression="message:INBOUND:http.status==201">  
    <flow-ref name=="flow2">  
    <when expression="message:INBOUND:http.status==503">  
    <flow-ref name="flow3">
    <when expression="payload instanceof java.lang.SocketException" evaluator="groovy">
    <flow-ref name="flow4">  
</flow>  

1 个答案:

答案 0 :(得分:1)

您可以使用MEL语法完成所有这些操作。

choice也需要一个otherwise块,在这种情况下决定你想要做什么。

<flow> 
    <http:outbound-endpoint address="${host}" exchange-pattern="request-response"/>
    <choice>
         <when expression="#[message.inboundProperties['http.status']==201]">  
             <flow-ref name=="flow2">  
         </when>
         <when expression="#[message.inboundProperties['http.status']==503]">  
             <flow-ref name="flow3">
         </when>
         <when expression="#[exception instanceof java.net.SocketException]">
             <flow-ref name="flow4">  
         </when>
         <otherwise>
         <!-- decide what you want to do here -->
         </otherwise> 
     </choice>
</flow> 
相关问题