问题
How do I use a filter other than a choice filter to call a subflow based on the http status?
<flow>
<http:outbound-endpoint exhange-pattern="request-response>
if http.status!=201
<flow-ref="subflow-to-invoke">
</flow>
回答1:
Check this post Mule-esb: Process Jersey Response based on Status code using Choice Router?
Here is snippet from the above link, that answers your question.
<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="#[payload instanceof java.lang.SocketException]">
<flow-ref name="flow4">
</when>
<otherwise>
<!-- decide what you want to do here -->
</otherwise>
</choice>
回答2:
You don't have to use a filter for that but a choice message processor:
http://www.mulesoft.org/documentation/display/current/Choice+Flow+Control+Reference
来源:https://stackoverflow.com/questions/19758138/mule-esb-mule-filter-based-on-http-status